简体   繁体   中英

JSF cannot update single form in ui:repeat from outside

I have two problems which are closely related:

  1. I need to update a form inside a tag inside ui:repeat from a dialog at the main page and cannot figure out how (because there are many tags in the ui:repeat and I need to update only one)
  2. naming containers are messed up and lose their "index" when I use id in that form (in case of trying to determine the update path expression...)

reason I need this: updating the 'wholelist' (current situation) breaks all <p:calendar> inside the <p:dialog> somehow (no errors...) (the calendar overlay shows at the first time, but after updating the list it does not appear any more (must reload page again). Also I don't want to update 100 elements each time if only one can be changed

page.xhtml

<h:panelGroup id="wholelist">
    <ui:repeat var="entry" value="#{bean.foundEntries}" id="repeatId">
        <customTag:someTag entry="#{entry}" />
    </ui:repeat>
</h:panelGroup>
... 
<p:dialog widgetVar="dialog" id="dialog">
    <p:calendar value="#{bean.date}" ... /> <!-- overlay pops up on select until the whole list is refreshed. after that it does not appear until page reload -->
    <p:commandButton actionlistener="#{bean.saveSomething()}" update="#{bean.componentToUpdate WHICH DOES NOT WORK...}"/>
</p:dialog>

someTag.xhtml

and within the <customTag:someTag> (which is a tag because of multiple reuses) :

 ...
    <h:form>
        ... display a lot of data which can be changed by the dialog...
        <p:commandButton value="show edit dialog" onComplete="PF('dialog').show()" update=":dialog">
           <f:setPropertyActionListener value="??? (@form does not work)" target="#{bean.componentToUpdate}" />
        </p:commandButton>
    </h:form>

First Question:

I need to refresh one single form from the dialog (=the dialog which needs to know which form I want to refresh, and I have no idea how to do so...)

And how can I get the update-logic working (pass the component to update to the bean so the dialog knows what to update or equal)?

Second Question:

why does JSF generate in case of not defining a id="..." to a naming container within a ui:repeat something like

  • repeatId:0:j_id_c0_6
  • repeatId:1:j_id_c0_6
  • repeatId:2:j_id_c0_6

and when I define a id to the form ( <h:form id="formname"> ) something like

  • repeatId:formname
  • repeatId:formname
  • repeatId:formname

which causes duplicateId (because the lack of the "iterator-number" in the name)?

Does this make sense?

I have solved it; error was elsewhere: I have forgotten in an included tag file which caused the js warning (which broke the calendar).

many thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM