bharanitharan
bharanitharan

Reputation: 2629

Hiding param value in URL - JSF Application

<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.

Upvotes: 1

Views: 4113

Answers (1)

BalusC
BalusC

Reputation: 1108722

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";
}

Upvotes: 4

Related Questions