JSF从bean添加参数

时间:2016-10-25 17:22:50

标签: primefaces jsf-2.2

我使用JSF 2.1和primefaces 6.0。 我在页面A中有一个commandButton,如下所示:

<p:commandButton value="GO" action="#{indexBB.clickSearchButton}" />

在backingbean函数中:

public String clickSearchButton() {
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
        FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("dateini", dateFormat.format(dateIni));
return "B?faces-redirect=true";
}

在第B页中,我尝试恢复值,但地图为空,刚刚创建的参数不再存在:

@PostConstruct
public void init() {
    Map<String,Object> parameterMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
    if(parameterMap.get("dateini") != null ){
        //assign the value
    }
}

如何从backingbean发送参数并在下一页中正确恢复? 我在这里看了一些没有结果的其他答案,例如:

How to add request parameter in jsf2?

我不想使用&f; f:param&#39;或类似的东西。

是的,有人能帮帮我吗? 提前谢谢。

0 个答案:

没有答案