jsf - Can not assign variable from another Beans with composite component in MyFaces -


version : myfaces 2.2.8

issues : have composite component assign value variable passed composite. works in mojara 2.2.12 (before im migrating myfaces 2.2.8).

this composite code : info.xhtml

<composite:interface>     <composite:attribute name="id" />     <composite:attribute name="methodtogetrecordfrominfo" method-signature="java.util.list action(id.co.sg.core.dto)" required="true" />     </composite:interface>  <p:datatable id="tblinfocodecomponent"   var="codecomponent"   value="#{infobean.grid}"      <p:columngroup type="header">         <p:row>             <p:column headertext="codecomponent"/>         </p:row>     </p:columngroup>      <p:column>           <p:commandlink value="#{codecomponent.map['componentcode']}"                   process="@this"                   icon="ui-icon-search"                   update="#{infobean.field.map['update']}">           <f:setpropertyactionlistener             value="#{infobean.wrap(codecomponent)}"             target="#{cc.attrs.methodtogetrecordfrominfo}" />           </p:commandlink>     </p:column>  </p:datatable> 

and method in composite bean code infobean.java

public dto wrap(dto codecomponentrecord) {     dto result = new dto();      result.putstring("callerid", "callerid");     result.putdto("record", codecomponentrecord.clone());      return result; } 

dto, kind of map object use simplify our works.

and how use in main xhtml

input.xhtml

<info:codecomponentinfo id="codecomponentinfo" methodtogetrecordfrominfo="#{inputbean.selectedinforecord}" />    

and code in inputbean.java

private dto selectedinforecord;  public void setselectedinforecord(dto infodto){      string id = infodto.getstring("callerid","");         activerow.putdto("codecomponent", infodto.getdto("record"));              }  public dto getselectedinforecord() {     return selectedinforecord; } 

when im use myfaces 2.2.8, setselectedinforecord method not invoke. so, can't result pick infobean in inputbean.

and saw article pass argument composite-component action attribute

so modified actual info.xhtml code one

<composite:interface>    <composite:attribute name ="beanname" type="java.lang.object"/>    <composite:attribute name ="methodname" type="java.lang.string"/> </composite:interface>  ...  <f:setpropertyactionlistener   value="#{infobean.wrap(codecomponent)}"   target="#{cc.attrs.beanname[cc.attrs.methodname]}" /> 

and new input.xhtml

<info:goodscodecomponentinfo id="goodscodecomponentinfo"  beanname="infobean" methodname="selectedinforecord"/>  

but found

error businessexceptionhandler - $$$$$ unhandled exception occured org.apache.myfaces.view.facelets.el.contextawarepropertynotfoundexception: javax.el.propertynotfoundexception: property 'selectedinforecord' not found on type java.lang.string

and try modify info.xhtml one

 <f:setpropertyactionlistener       value="#{infobean.wrap(codecomponent)}"       target="#{cc.attrs.beanname.methodname}" /> 

or one

<f:setpropertyactionlistener     value="#{infobean.wrap(codecomponent)}"     target="#{cc.attrs.beanname.selectedinforecord}" /> 

and still have same error above..

so try mod once again one

<f:setpropertyactionlistener     value="#{infobean.wrap(codecomponent)}"     target="#{inputbean.selectedinforecord}" /> 

it works !!! not need, need passing bean name parameters.

anyone can me solve case?

i'm using java 8 , tomcat 8.0.30 , el 3

i have checked problem looking possible bug, there no bug. instead, related understand how f:setpropertyactionlistener works.

this tag set value retrieved el expression property pointed "target" attribute. if try call method using "target" attribute not work, because not how designed.

the right way in way:

<info:codecomponentinfo bean="#{inputbean}" methodname="selectedinforecord"/>

and in composite component:

<cc:attribute name ="bean" type="java.lang.object"/> <cc:attribute name ="methodname" type="java.lang.string"/> .... <f:setpropertyactionlistener                 value="#{infobean.wrap(codecomponent)}"                 target="#{cc.attrs.bean[cc.attrs.methodname]}" /> 

the key thing here need pass reference bean, , in way chain correctly solved.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -