开发者

JSF 2.0 redirect with parameters

开发者 https://www.devze.com 2023-01-25 20:29 出处:网络
I my Java EE application I have articles administration. There is url like http://localhost:8080/articles/detail.xhtml?article=70 where article means id of article. This page displays article comments

I my Java EE application I have articles administration. There is url like http://localhost:8080/articles/detail.xhtml?article=70 where article means id of article. This page displays article comments etc. it is not important. But there is button Edit and I would like to redirect on page edit.xhtml but user should still see http://localhost:8080/articles/detail.xhtml?article=70 because I don't want t开发者_运维技巧he edit page to be bookmarkable.

Can you help me how to set up faces-config to change page but not url? I thought that if I don't write <redirect /> then url would stay same but I was wrong. Url changes from detail.xhtml?article=70 to detail.xhtml

Thanks for any advise.


I'd suggest to bring in some ajaxical powers so that no synchronous request is fired.

<h:panelGroup id="article" layout="block">
    <h:panelGroup rendered="#{!bean.editmode}">
        View article (can if necessary be an ui:include)
        <h:form>
            <h:commandButton value="Edit" action="#{bean.edit}">
                <f:ajax render=":article" />
            </h:commandButton>
        </h:form>
    </h:panelGroup>
    <h:panelGroup rendered="#{bean.editmode}">
        Edit article (can if necessary be an ui:include)
        <h:form>
            <h:commandButton value="Save" action="#{bean.save}">
                 <f:ajax render=":article" />
            </h:commandButton>
        </h:form>
    </h:panelGroup>
</h:panelGroup>

Bean:

private boolean editmode;

public void edit() {
    this.editmode = true;
}

public void save() {
    this.editmode = false;
}

public boolean isEditmode() {
    return editmode;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消