File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Using f:setPropertyActionListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Using f:setPropertyActionListener" Watch "Using f:setPropertyActionListener" New topic

Using f:setPropertyActionListener

Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384

I am trying to pass two parameters i.e. (nomComposantARejouer, typeFileARejouer) to an action method (gestionnaireMessagesController.rejouerMessage) using the setPropertyActionListener (we use jsf 1.2).

Here is the relevant jsp code:

However, I always get a NPE because both parameters are null when used in the action method:

FYI, the variables and can be displayed without problem and are not null.

Also ignore the h:columnHeaderFacet tags. They are inhouse tags that I've renamed.

I am not sure what I am getting wrong. Can anyone please help?

Yeray Santana Borges
Ranch Hand

Joined: Mar 02, 2008
Posts: 46
I think that your code is doing something wrong in the getter and setter of nomComposant and typeFile. Could you write them?, what is the scope of your bean and how are you initializing the nomComposant and typeFile variables?

In my opinion you should remove the setPropertyActionListener, I think that you don't need them.
When you are clicking on commandLink "rejouer", first you are getting the value of nomComposant to assign it to nomComposantARejouer (getters and setter will be called before your code enter in rejouerMessage() method), maybe you can use directly the value of nomComposant in your backed bean when you are in rejouerMessage(), something like this:

Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
Thank you for your reply Yeray.
I finally went on to use f:param which works well in my case.
I agree. Here's the link:
subject: Using f:setPropertyActionListener
It's not a secret anymore!