简体   繁体   English

JSF无法从外部更新ui:repeat中的单个表单

[英]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) 我需要从主页上的对话框更新ui:repeat内的标签内的表单,并且无法弄清楚如何处理(因为ui:repeat中有很多标签,我只需要更新一个)
  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...) 当我以这种形式使用id时,命名容器会混乱并且丢失其“索引”(以尝试确定更新路径表达式的情况...)

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 我需要这样做的原因:更新“批发清单”(当前情况)会以某种方式(没有错误...)破坏<p:dialog>内的所有<p:calendar> (日历覆盖图是第一次显示,但是更新了列出它不再出现(必须再次重新加载页面)。如果只更改一个元素,我也不想每次都更新100个元素

page.xhtml 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 someTag.xhtml

and within the <customTag:someTag> (which is a tag because of multiple reuses) : 并在<customTag:someTag> (由于多次重用而成为标签)内:

 ...
    <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)? 以及如何使update-logic起作用(将组件传递给Bean以使对话框知道要更新或等于什么)?

Second Question: 第二个问题:

why does JSF generate in case of not defining a id="..." to a naming container within a ui:repeat something like 如果未在ui内的命名容器中定义id =“ ...”的情况下,JSF为何生成:重复类似

  • repeatId:0:j_id_c0_6 repeatId:0:j_id_c0_6
  • repeatId:1:j_id_c0_6 repeatId:1:j_id_c0_6
  • repeatId:2: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 当我定义<h:form id="formname"><h:form id="formname"> )时,类似

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

which causes duplicateId (because the lack of the "iterator-number" in the name)? 哪个会导致重复的ID(因为名称中缺少“迭代器编号”)?

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). 错误在其他地方:我忘记了一个包含在内的标记文件,该文件引起js警告(这破坏了日历)。

many thanks 非常感谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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