EL variable resolution in JSF: is there a way to control when it happens? -


i face following problem. have jsf application , facelet write el expressions, this:

<h:outputtext value="#{mybean.foo}"> 

as long mybean, variable, has life long enough, there's no problem evaluate mybean.foo @ given time, if mybean variable references bean within short period of time, when mybean.foo evaluated might late, jsf complains mybean resolves null. well-known, problem is not clear me expect in different situations.

concrete example n. 1: if try following primefaces orderlist:

<p:orderlist value="#{bean.myvalue}" var="item">   <p:column>     <p:commandlink action="#{bean.dosomething(item)}" />   </p:column> </p:orderlist>` 

this not going work, because when dosomething called, item variable no longer defined (although object references still alive) , hence it's resolved null. it's known issue. same pattern works fine <p:datatable>, instance. anyway, i'm not interested right in specific problem, want explain doubt.

concrete example n. 2: have written composite component backing bean. backing bean extends uinamingcontainer , uses statehelper retain model object. composite allows write child tags , write this:

<myns:mycc var="myvar">   <h:inputtext value="#{myvar.foo}" /> </myns> 

with "myvar" want give name model object. make work, tried store model object in request map @ beginning of encodechildren method , remove afterwards: works rendering, if process input commandbutton action, not work because when action gets executed says myvar can't resolved: in other words, tries resolve entire expression late. tried "permanently" save model object in view scope map, doens't work either. however, if change to:

(assuming modelobject property field in backing bean stores model object) works. so, not problem in model, in way try make model object available el expressions child tags.

concrete example n. 3: use <ui:param> tag give beans shorter name , ease templating. instance:

<ui:param name="bean" value="#{longnamedandpagespecificbean}" /> 

so that, in remainder of page can use #{bean.foo} instead of #{longnamedandpagespecificbean.foo}. works fine actions passed command buttons. however, if pass method expression #{bean.myactionmethod} composite component attribute declared method-signature, when method expression invoked receive error bean resolves null... reason why works in 1 case (with commandbutton actions) , not in other (with actions used composite component) big source of confusion me.

i appreciate if can me understand better jsf aspect , suggest better approaches/workarounds aforementioned concrete examples.

your question looks large, that, during build time session , request scoped values avaiaible.

the same thing true execution phase.

only render phase should ensure avaibility of temporal vars "myvar".

the best way understand realy hapening debug because depends on component implementation


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -