f:param doesn't work with h:commandButton

i'm using eclipse 3.6.2 (Helios) , Tomcat 7 , MyFaces 1.2.9

i have no problem when i use f:param into the h:commandLink but when i put f:param into h:commandButton it doesn't work . what's the problem ?

this sample work fine :

<h:commandLink value="Click here" action="#{myBean.action}">
<f:param name="parameterName1" value="parameterValue1" />
<f:param name="parameterName2" value="parameterValue2" />
</h:commandLink>

but it doesn't

<h:commandButton value="Click here" action="#{myBean.action}">
<f:param name="parameterName1" value="parameterValue1" />
<f:param name="parameterName2" value="parameterValue2" />
</h:commandButton>

Answers


In JSF 1.x, the <f:param> is only supported in <h:commandLink>, <h:outputLink> and <h:outputFormat>, not in <h:commandButton>. That support is only in JSF 2.0 and newer.

You have at least 4 options:

  1. Use <h:commandLink> instead. If necessary use CSS to style it to look like a button. See for an example also JSF commandButton URL parameters.

  2. Use <f:attribute> or <f:setPropertyActionListener> instead. See also Communication in JSF.

  3. Pass them as method arguments action="#{myBean.action('param1', 'param2')}". Tomcat 7 is a servlet 3.0 container which supports EL 2.2 which in turn supports passing method arguments. You only need to make sure that your web.xml is declared conform Servlet 3.0. See also Invoking methods with parameters by EL in JSF 1.2.

  4. Upgrade to JSF 2.0. It offers so much advantages over JSF 1.x. See also Migrating from JSF 1.2 to JSF 2.0 and Communication in JSF 2.0.


Need Your Help

$_POST/$_REQUEST Variables not being set in PHP/Codeigniter/Apache

php apache codeigniter post

First, on a local install of XAMPP, this works perfectly well. However, on an external (WAMP) server, it does not.

How to avoid repeatig DAO methods in Service classes? @Transactional annotated DAO and Service classes - is it acceptable practice?

java spring transactions annotations dao

I know that the best practice is having both service and dao layers and to add @Transactional annotations on the service level. But in my case it means most of my service classes is created just to

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.