开发者

Hiding param value in URL - JSF Application

开发者 https://www.devze.com 2023-04-12 08:26 出处:网络
<h:outputLink value=\"#{beanname.path}\"> <h:outputText value=\"Output label\"></h:outputText>
<h:outputLink value="#{beanname.path}">
    <h:outputText value="Output label"></h:outputText>
    <f:param name name="name" value="tommy"/>
</h:outputLink>
开发者_开发技巧

http://127.0.0.1:7101/projectt/faces/index.jsp?name=tommy my URL appears with the param value. I want to hide it in the URL and get it in the bean class.


So, you want a POST request? Use <h:commandLink> instead.

<h:form>
    <h:commandLink value="Output label" action="#{beanname.outcome}">
        <f:param name name="name" value="tommy"/>
    </h:commandLink>
</h:form>

The parameter can be set as

@ManagedProperty("#{param.name}")
private String name;

or can passed by <f:setPropertyActionListener> instead:

<h:form>
    <h:commandLink value="Output label" action="#{beanname.outcome}">
        <f:setPropertyActionListener target="#{beanname.name}" value="tommy"/>
    </h:commandLink>
</h:form>

or when you're already on a Servlet 3.0 / EL 2.2 capable container (Tomcat 7, Glassfish 3, etc), just pass it as action method argument:

<h:form>
    <h:commandLink value="Output label" action="#{beanname.outcome('tommy')}" />
</h:form>

with

public String outcome(String name) {
    // ...

    return "index";
}
0

精彩评论

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

关注公众号