小编Adr*_*anX的帖子

在回发中保留原始GET请求参数

我只是页面与关联的@RequestScoped支持bean.我从其他页面到达此页面,我在其中传递参数"project".所以,当我进入正确的页面时,我会像contextRoot/faces/jsf.xhtml?project=123.

视图:

<f:metadata>
    <f:viewParam name="project" value="#{entityBean.projectId}" />
</f:metadata>       
...
<p:commandButton value="#{msg['button.add']}"
    actionListener="#{entityBean.addNewEntity((entityName),(entityDescritpion))}"
    ajax="true" update=":projectDetailForm"/>
Run Code Online (Sandbox Code Playgroud)

支持豆:

@Named("entityBean")
@RequestScoped
public class EntityBean implements Serializable{
    private String projectId;

    @PostConstruct
    public void init() {
        params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();

        for (Map.Entry<String, String> entry : params.entrySet()) {
            System.out.println(entry.getKey() + " / " + entry.getValue());
        }

        if (params.get("project") != null) {
            projectId = params.get("project");
        } else {
            HttpServletRequest request =
                (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
            String projectId = request.getParameter("project");
        }
    }

    //projectId getter and setter
    //public void addNewEntity(String …
Run Code Online (Sandbox Code Playgroud)

jsf jsf-2

5
推荐指数
1
解决办法
3746
查看次数

标签 统计

jsf ×1

jsf-2 ×1