This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF GURU help needed: concerns page refreshing & updating .jsp content upon clicking button  RSS feed

 
Andriy Burachinskiy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, guys. Thanks in advance for reading my post and trying to help. I have the following problem:

I need a page to be refreshed and populated with new values upon clicking on <h:selectOneMenu> in browser.

How I try to accomplish this:
--------------------------------------------------------------------------------------------------
<h:selectOneMenu value="#{SubmitReport.projectName}"
styleClass="common-dropdown" required="true"
onchange="this.form.submit();">
<!-- onchange="this.form.submit();" -->
<f:selectItems value="#{SubmitReport.loggedUserProjects}"/>
</h:selectOneMenu>
...
--------------------------------------------------------------------------------------------------

By this I want to invoke all the JSF lifecycle (as if I were clicking submit button):

--------------------------------------------------------------------------------------------------
<h:commandButton value="Submit" id="SubmitCommand" action="#{SubmitReport.submitReport}">
<h:messages infoStyle="info"/>
</h:commandButton>
--------------------------------------------------------------------------------------------------

What do I need this for? Here is my submitReport method:

--------------------------------------------------------------------------------------------------
public String submitReport() {
if (!isPageRefreshNeeded()) {
// refreshPageUponProjectChange();
return "submit_success";
}
else {
//instantiate Report and persist it to DataBase
}
}
-------------------------------------------------------------------------------------------------
where isPageRefreshNeeded - getter for boolean property pageRefreshNeeded (in .jsp page it is represented by <h:inputHidden ...>). The problem is that my SubmitReport () method is never invoked.

Perhaps I could do this with an eventListener, but this seems useless to me because I have to update .jsp page and insert into it new values from DataBase according to selected by a user item in SelectItems List. As far as I understand I need make javascript invoke full JSF lifecycle and bind it to some backingBean's property/method, where I can do all the necessary DataBase stuff.

If You have some ideas, I'll be graceful.
 
nitin pokhriyal
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need here a valuechangelistner. and in that one you invoke your refreshPageUponProjectChange() to change the values. I don't know which implementation you are using. But you can use richfaces that will be very easy task for you
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Search back to somewhere around June of this year and I think you'll find some code I posted where I have a 3-level selectOneMenu structure (Country, State, City) with dynamic updates using RichFaces and a valueChangeListener.

Also, I know it sounds like nitpicking, but it's better not to say ".jsp" updating. It's a View. When you say "JSP", I get confused because I can't tell whether you're referring to a non-JSF JSP or a JSF View. Plus, in my case, my ".jsp" files are Facelets ".xhtml" files, but the same rules still apply because what's important isn't what the filename extension is, it's that they're still JSF View definitions.
 
Andriy Burachinskiy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for responding, hope your hints will help me.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!