How to pass parameter value from JSF to backing bean

In my backing bean I have a variable, and I would like to give a value of that from the JSP page (the value of the parameter will be hardcoded in JSP) . I am thinking of using <f:param> tag using binding, but not able

to make it work.

public class mybean{

String myparam = "";

public void getMyparam(){

}

public String setMyparam(String myparam){

this.myparam = param

}

}

thanks

-K

[460 byte] By [ketha] at [2007-10-3 0:36:41]
# 1
Check http://balusc.xs4all.nl/srv/dev-j2p-com.html how to use f:param.
BalusCa at 2007-7-14 17:30:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
That is using <h:CommandLink> tag.But, I just need to initialize the bean with some data from jsp. Is there any way of doing that?Thanks-k
ketha at 2007-7-14 17:30:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
This should be able using scriplets.But you're talking about hardcoded data in JSP? Consider propertiesfiles, this is a much cleaner way of maintaining hardcoded data.
BalusCa at 2007-7-14 17:30:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

How about:

JSP page:

<h:commandLink action="#{myBean.someAction}">

<h:outputText value="Link Text"/>

<f:param name="someParamName" value="someValue"/>

</h:commandLink>

Backing bean code:

public String someAction() {

ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();

HttpServletRequest request = (HttpServletRequest) context.getRequest();

String parameterValue = request.getParameter("someParamName");

// Code here

return null;

}

Gamigina at 2007-7-14 17:30:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Do you have read the question and the replies?
BalusCa at 2007-7-14 17:30:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

If it is a request scoped managed bean, you can confiure it so:

...

<managed-bean>

<managed-bean-name>bean>/managed-bean-name>

...

<managed-property>

<property-name>myParam</property-name>

<value>#{requestScope.myParam}</value>

</managed-property>

...

Before calling the JSP set the request attribute myParam.

agoriaa at 2007-7-14 17:30:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...