aspose file tools
The moose likes JSF and the fly likes JSF GURU help needed: concerns page refreshing & updating .jsp content upon clicking button Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "JSF GURU help needed: concerns page refreshing & updating .jsp content upon clicking button" Watch "JSF GURU help needed: concerns page refreshing & updating .jsp content upon clicking button" New topic
Author

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

Andriy Burachinskiy
Greenhorn

Joined: Dec 31, 2008
Posts: 17
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

Joined: May 19, 2005
Posts: 263
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
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14491
    
    7

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Andriy Burachinskiy
Greenhorn

Joined: Dec 31, 2008
Posts: 17
Thanks for responding, hope your hints will help me.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF GURU help needed: concerns page refreshing & updating .jsp content upon clicking button
 
Similar Threads
Help with Send Email on submit
Problem regarding the ValueChangeEvent and the commandButton
<h:selectOneMenu problem. Please, Gurus, I need Your help.
Submit causes valuechangelistener to run
A Problem with events