jsf 2 - How to call the same method after every include of a .xhtml page in JSF? -
i have following part of .xhtml page:
<ui:composition template="./templates/template.xhtml"> <ui:define name="maincontent"> <ui:include src="include/includeableeditor.xhtml"> <ui:param name="includeparam" value="myclass" /> </ui:include> <ui:include src="include/includeableeditor.xhtml"> <ui:param name="includeparam" value="yourclass" /> </ui:include> </ui:define> in "includeableeditor.xhtml" want call method after included (in case should happend 2 times).
now tried solve this: (metadata tag part of includeableeditor.xhtml)
<f:metadata> <f:event type="prerenderview" listener="#{editor.onload}" /> <f:attribute name="textfieldid" value="#{includeparam}" /> </f:metadata> the problem:
the method being called once. should called 2 times. once parameter "myclass" , once "yourclass".
do have suggestions?
thanks lot!
there can 1 <f:metadata> in entire view , must in top level view. unlike e.g. <f:view>, don't "extend" each other , others ignored.
you don't need here. it's necessary whenever need attach <f:viewparam> and/or <f:viewaction> specific view. <f:event> doesn't require <f:metadata>. hooked parent uicomponent. during jsf 2.0/2.1 ages (when <f:viewaction> didn't exist) being abused have hook invoke listener after <f:viewparam> values being set. it's self-documentary purposes being placed in same <f:metadata> <f:viewparam>s are.
so, rid of it.
<f:event type="prerenderview" listener="#{editor.onload(includeparam)}" /> that said, postaddtoview better event hook on. , avoid "duplicate component id" errors on place later on, consider wrapping in <f:subview> or making composite.
Comments
Post a Comment