Forums Register Login

Setting Bean property

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
Dear Shimi
you may use <h:inputHidden ... > on every page.
and put your own diffrent value (eg your page name) at each page.


regards
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
"shimi k", please check your private messages for an important administrative matter.
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
 

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.
It's just like a fortune cookie, but instead of a cookie, it's pie. And we'll call it ... tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2969 times.
Similar Threads
Invalid state exception in accessing managed bean
How can I set bean property in JSF page?!
Can I use jsps and jsfs both in my application?
Setting Values for Bean Properties
JSTL to retrieve and pass request objects
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 12:33:20.