jsf 2 - commandButton doesn't set correctly f:param if it got a javascript method in onclick event -


between 2 jsf views xhtmls (both have view scoped backing beans) pass parameters if user click link or button. if have attribute onclick javascript function open page (in page use parameters set in first page) commandbutton or commandlink f:param attributes \'currentaccess\':\'3\',\'gridno\':\'5\', , if don't have onclick attribute have right 'currentaccess':'3','gridno':'5', if have:

<h:commandbutton action="#{statisticsbean.showaccessincorectanswers()}" target="_blank"     value="#{strings.whathavedodonewrong}" rendered="#{o.date != '-' , o.answernowrong != 0}">     <f:param name="currentaccess" value="#{o.currentaccess}"/>           <f:param name="gridno" value="#{o.nogrid}"/>     <f:param name="gridcategory" value="#{o.category}"/> </h:commandbutton> 

the html rendering looks like:

<input type="submit" name="j_idt73:0:j_idt74:j_idt77" value="ce ai gresit" onclick="mojarra.jsfcljs(document.getelementbyid('j_idt73:0:j_idt74'),{'j_idt73:0:j_idt74:j_idt77':'j_idt73:0:j_idt74:j_idt77','currentaccess':'1','gridno':'5','gridcategory':'drept procesual civil'},'');return false" /> 

which good, have access parameters (f:viewpara or facescontext , use last 1 likefacescontext.getcurrentinstance().getexternalcontext().getrequestparametermap().get("currentaccess"))

but if have:

<h:commandbutton action="#{statisticsbean.showaccessincorectanswers()}" target="_blank"     onclick="confirmgridstatistics('#{strings.doyouwanttoseethewronganswersinaccessno} #{o.currentaccess} #{strings.fromdate} #{o.date}?');"     value="#{strings.whathavedodonewrong}" rendered="#{o.date != '-' , o.answernowrong != 0}">         <f:param name="currentaccess" value="#{o.currentaccess}"/>         <f:param name="gridno" value="#{o.nogrid}"/>         <f:param name="gridcategory" value="#{o.category}"/> </h:commandbutton> 

with javascript function in onclick event rendering:

<input type="submit" name="j_idt73:2:j_idt74:j_idt77" value="ce ai gresit" onclick="jsf.util.chain(this,event,'confirmgridstatistics(\'vrei sa vezi raspunsurile gresite in accessul 3 din data de 16-05-2013?\');','mojarra.jsfcljs(document.getelementbyid(\'j_idt73:2:j_idt74\'),{\'j_idt73:2:j_idt74:j_idt77\':\'j_idt73:2:j_idt74:j_idt77\',\'currentaccess\':\'3\',\'gridno\':\'5\',\'gridcategory\':\'drept procesual civil\'},\'\')');return false" /> 

and in second views backing bean null parameters facescontext. why that?

update thought that

facescontext.getcurrentinstance().getexternalcontext().getrequestparametermap().put("currentaccess", access); in action method whould solve it. doesn't, gives me java.lang.unsupportedoperationexception

i don't know why happening.

i have resolved issue hack. still don't know why issue described parameters.

my solution (i know it`s hack):

  • the javascipt function among other thing opened second view (to wanted pass parameters)
  • so have put parameters (which want pass) javascipt function

    <h:commandbutton action="#{statisticsbean.showaccessincorectanswers()}" target="_blank"     onclick="confirmgridstatistics('#{strings.doyouwanttoseethewronganswersinaccessno} #{o.currentaccess} #{strings.fromdate} #{o.date}?'     , '#{o.currentaccess}', '#{o.nogrid}', '#{o.category}');" value="#{strings.whathavedodonewrong}" rendered="#{o.date != '-' , o.answernowrong != 0}"/> 

and second view request url looks http://myserver:port/access.xhtml?currentaccess=34&nogrid=3&category=category

and in second view backing bean access parameters

httpservletrequest request = (httpservletrequest)facescontext.getcurrentinstance().getexternalcontext().getrequest(); string currentaccess= request.getparameter("currentaccess"); 

still if knows why initial issue appreciate share. thank you.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -