2013-05-19 14 views
0

两人之间JSF意见xhtmls(两者都具有视图范围的支持bean)我想传递参数,如果用户点击一个链接或按钮。如果我有一个属性用JavaScript函数打开另一个页面的onclick(在本页面我想用在第一页设置参数)到命令或commandLink我得到的f:param属性是\'currentAccess\':\'3\',\'gridNo\':\'5\',,如果我不有一个onclick属性我是不是正确的'currentAccess':'3','gridNo':'5', 如果我有:的commandButton设置不正确F:PARAM,如果它得到了在onclick事件JavaScript方法

<h:commandButton action="#{statisticsBean.showAccessIncorectAnswers()}" target="_blank" 
    value="#{strings.whatHaveDoDoneWrong}" rendered="#{o.date != '-' and 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> 

HTML呈现的样子:

<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" /> 

这是很好的,我有机会获得参数(F:viewpara或FacesContext中,我使用最后一个像FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("currentAccess")

如果我有:

<h:commandButton action="#{statisticsBean.showAccessIncorectAnswers()}" target="_blank" 
    onclick="confirmGridStatistics('#{strings.doYouWantToSeeTheWrongAnswersInAccessNo} #{o.currentAccess} #{strings.fromDate} #{o.date}?');" 
    value="#{strings.whatHaveDoDoneWrong}" rendered="#{o.date != '-' and 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> 
在onclick事件的JavaScript函数

我得到的渲染:

<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" /> 

,并在第二个意见支持豆我得到null为来自FacesContext的参数。这是为什么?

UPDATE 我认为

的操作方法FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().put("currentAccess", access);解决对子级它。但它没有,它给了我一个java.lang.UnsupportedOperationException

我不知道为什么会这样。

回答

0

我已经解决了我的一个黑客攻击的问题。我仍然不知道为什么用参数描述的问题。

我的解决方案(我知道it`sa砍):

  • 除其他事情SCRIPT关闭打开了我的第二个观点(而我想传递的参数)
  • 所以我已经把参数(我想传递)到SCRIPT关闭

    <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 != '-' and o.answerNoWrong != 0}"/> 
    

和所述第二视图的请求URL看起来像http://myserver:port/access.xhtml?currentAccess=34&noGrid=3&category=category

,并在第二视图支持bean我访问参数与

HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest(); 
String currentAccess= request.getParameter("currentAccess"); 

STILL 如果有人知道这是为什么我将不胜感激共享初始问题。 谢谢。

相关问题