我使用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;或类似的东西。
是的,有人能帮帮我吗? 提前谢谢。