Get updated value from bean through JavaScript in JSF -


i have context menu in itemcomp.xhtml , if click on item in context menu action itemdisplay.refreshitems called , on complete of action javascript function showpanel() called

itemcomp.xhtml

<rich:contextmenu disabledefaultmenu="true" event="oncontextmenu" submitmode="ajax">     <rich:menuitem disabled="true" style="color:black; font-weight:bold;" value="items"/>     <rich:menuseparator/>      <c:foreach items="#{itemdisplay.componenttypemap.keyset}" var="itemvalue">         <rich:menuitem value="#{itemvalue}"                        rendered="#{(itemvalue == 'bags report') or                                    (itemvalue == 'chairs report') or                                    (itemvalue == 'tables report')}"                        action="#{itemdisplay.refreshitems}"                        oncomplete="showpanel( '#{itemvalue}','#{item.id}')">         </rich:menuitem>     </c:foreach> </rich:contextmenu> 

in refreshitems() of itemdisplaybean.java, setting variables true.

itemdisplaybean.java

private boolean availablebags = false;

public boolean getavailablebags() {     return this.availablebags; }  public void setavailablebags(boolean availablebags) {     this.availablebags = availablebags; } private boolean availablebags = false;  public boolean getavailablebags() {     return this.availablebags; }  public void setavailablebags(boolean availablebags) {     this.availablebags = availablebags; } private boolean availablechairs = false;  public boolean getavailablechairs() {     return this.availablechairs; }  public void setavailablechairs(boolean availablechairs) {     this.availablechairs = availablechairs; } private boolean availabletables = false;  public boolean getavailabletables() {     return this.availabletables; }  public void setavailabletables(boolean availabletables) {     this.availabletables = availabletables; }  public string refreshitems() {     setavailablebags(true);     setavailablechairs(true);     setavailabletables(true); } 

and in itemdisplay.xhtml, have javascript function showpanel() follows.

function showpanel(item, itemid) {      if (item == 'bags report') {         if (#{itemdisplay.availablebags})             richfaces.showmodalpanel('bags');         else             alert('no bags found');     } else if (item == 'chairs report') {         if (#{itemdisplay.availablechairs})             richfaces.showmodalpanel('chairs');         else             alert('no chairs found');     } else if (item == 'tables report') {         if (#{itemdisplay.availabletables})             richfaces.showmodalpanel('tables');         else             alert('no tables found');     } } 

and problem here -- in javascript function, not getting updated backing bean values, hence availablebags ( if( #{itemdisplay.availablebags} ))is false (even though set true in backing bean), , panel not shown. if refresh page updated value backing bean ( if( #{itemdisplay.availablebags} ) true , panel shown.any 1 can me why getting updated value refreshing page.

as pointed out el expressions evaluated when page renders , become static text.

you can use @data, e.g.:

<rich:menuitem data="#{itemdisplay.availablebags}"      oncomplete="showpanel('#{itemvalue}', event.data)" … > 

event.data contain current value of property (you can point object).

edit: in richfaces 3.x js parameter data


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -