This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes How can I set bean property in JSF page?!    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How can I set bean property in JSF page?!    " Watch "How can I set bean property in JSF page?!    " New topic
Author

How can I set bean property in JSF page?!

Pavels Hlopoks
Ranch Hand

Joined: Feb 05, 2007
Posts: 31
Hello!

I have



have jsp page




and have faces.xml






when I run it, get in output

"
--- first---
--- first---
"
I other words JSTL <c:set /> is not working... Why?

Please help me...
Josh Juneau
Ranch Hand

Joined: Jun 16, 2004
Posts: 86
I do not know if the JSTL "set" will work with JSF. However, can't you just use another variable for the second level output? If you are looking to have both of the values appear on the same page then you would be making a cleaner solution by using two separate variables in my opinion.


Database Administrator/Application Developer
Pavels Hlopoks
Ranch Hand

Joined: Feb 05, 2007
Posts: 31
Josh, thanks for your response ;)

But I really need to set managed bean property from jsf page. In our architecture it is required for menu...

Sombody can answer me - how can set managed bean property from JSF page?
[ June 03, 2007: Message edited by: Pavels Hlopoks ]
zohreh talebi
Ranch Hand

Joined: Sep 01, 2006
Posts: 41
Dear Pavels,

If you don't force to use JSTL , you can set the bean properties by JSF easy.
Look:

UserBean bean = new UserBean(); // your bean class

ExternalContext context =
FacesContext.getCurrentInstance().getExternalContext();
HttpServletRequest request =
(HttpServletRequest)context.getRequest();

String fullName = request.getParameter("form1:fullName");
bean.setFullName(fullName);

you can do this in utility class.

I hope it can help you.

Zohreh
Pavels Hlopoks
Ranch Hand

Joined: Feb 05, 2007
Posts: 31


Hmmm ... For example managed bean in faces config looks like :



How I can get it from request?

Why you wrote: String fullName = request.getParameter("form1:fullName");

Why "form1:fullName"??
zohreh talebi
Ranch Hand

Joined: Sep 01, 2006
Posts: 41
Ok ,

How I can get it from request?
By this:

ExternalContext context =
FacesContext.getCurrentInstance().getExternalContext();
HttpServletRequest request =
(HttpServletRequest)context.getRequest();

Why you wrote: String fullName = request.getParameter("form1:fullName");

beacuase of this is for example your JSP :

<h:form id="form1" >
First Name :
<h:inputText id ="fullName" value="#{dbBean.fullName}"/>

Zohreh
Pavels Hlopoks
Ranch Hand

Joined: Feb 05, 2007
Posts: 31
zohreh, are you sure?


I have jspx page :





how can see i try get bean from request...




And I have some bean - how Can I get HeaderBacking from request?

when I try get all RequestParemeterNames - I can't see my "headerBacking", like in faces config...


zohreh talebi
Ranch Hand

Joined: Sep 01, 2006
Posts: 41
I don't know about jspx pages and i don't sure So ,sorry.
Can you tell me something about it.
Pavels Hlopoks
Ranch Hand

Joined: Feb 05, 2007
Posts: 31
jspx is jsp page in xml syntax.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How can I set bean property in JSF page?!
 
Similar Threads
How do I preload bean for editing?
Bean value doubt
querystring values and GET method
PropertyNotFoundException
JSF, EJB3 target unreachable, returned null