Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting Bean property  RSS feed

 
shimi k
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a bean which is used by a few JSF pages. I am looking for a way to set the bean property using the JSF page and not by a user input. It should be different between different pages so I can't set it in the faces-config.xml file.
Does anyone knows how this can be done?
 
Amir Iqbal
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Shimi
you may use <h:inputHidden ... > on every page.
and put your own diffrent value (eg your page name) at each page.


regards
 
shimi k
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amir,

Can you give me an example? I tried using h:inputHidden but I guess I did something wrong.

Lets say I have the following Bean:
public class MyBean {
private String name;

public String getName() {
return name;
}

public void setName(String newName) {
this.name = newName;
}
}

I want to set the value as 'JSF Page'.
I tried this: <h:inputHidden id="nameId" binding="#{myBean.name}" value="JSF Page"/>
and I got: java.lang.IllegalArgumentException: argument type mismatch

Can you tell me what is the right way to to use the inputHidden
 
shimi k
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have managed to do it by removing the binding parameter from the inputHidden and I used request.getParameter() in my Bean.

Is there any other way to do it from the JSF page without modifying the Bean?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65832
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"shimi k", please check your private messages for an important administrative matter.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amir Iqbal wrote:Dear Shimi
you may use <h:inputHidden ... > on every page.
and put your own diffrent value (eg your page name) at each page.


regards

You didnĀ“t understand the purpose of h:inputHidden.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shimi k wrote:I have managed to do it by removing the binding parameter from the inputHidden and I used request.getParameter() in my Bean.

Is there any other way to do it from the JSF page without modifying the Bean?

Use f:setPropertyActionListener.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!