Updating ui:defined form content from Master template (JSF & Primefaces)

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-14 03:15:14

问题


I am having a little trouble with my web-app, essentially I keep getting an warning message:

INFO: Cannot find component with identifier "formName" in view.

I know why this is happening, but I just need to determine if their is a fix/better solution.

Basically I have a master template file that contains a number of <p:dialog> components, which have various CRUD capabilities. When a user interacts with these components I use the inbuilt primefaces 'update' function to ajaxically update the various forms/components in the <ui:defined> page(s). However, because of the layout the JSF web-app (i.e. Master template and ui:defined web pages) and the fact that I have defined these components in the Master template file, it means that the update-able forms/components are not necessarily in the current view and throwing the warning message above.

For Example:

If I had my Master Template file: master.xhtml with a component called <p:dialog id="componentA" />. And then I had page1.xhtml with a <h:form id=page1Form/> and similarly I have a page2.xhtml with <h:form id=page2Form/>, which both contained information provided by a sessionscoped backing bean, what would be the best method to ensure that these forms are updated if a CRUD operation occurs using componentA? At the moment I am simply using <p:dialog id="componentA" update="page1Form, page2Form" /> but because only page1 or page2 are is in the view, Tomcat spits out the above message. So is it possible to dynamically specify the forms/components to update dependant on the page I am on, or do I have to specify componentA on every <ui:define> page (which would be lots of repeating html/code and not particularly manageable) or is there a method to update all forms/components in the current view? Or is what I am doing correct and I should just turn off development mode in my web.xml to cease the messages?

Cheers

Ally


回答1:


Just to confirm, if anyone stumbles upon this thread. I managed to fix my above problem by using the <ui:param name="paramName" value:"a value"/> value.

Essentially in your master template file specify your component like you would i.e.

<p:commandButton value="Submit" action="#{someBean.doSomeStuff()}"
update="#{paramName}" />

Then in your <ui:composition> page you simply state param name and its value:

<ui:param name="paramName" value="someForm someOtherForm"/>

jobs a goodun!



来源:https://stackoverflow.com/questions/9263193/updating-uidefined-form-content-from-master-template-jsf-primefaces

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!