• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need my rich:tree to be re loaded when I add a new entity to it

 
Village Idiot
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a rich:Tree that lists projects, devices and channels, one under the other. Its finally working great, plus I have the code and pages in place to either add new entities to any of this stuff, or edit the ones that are there.

Of course once you edit or add something, the rich:tree needs to change to reflect this. The tree is getting its data from a web service that holds xml btw.

But as of right now, the only way i can get this change to show up, is after I add or edit something, I have to close down eclipse and restart it, as well as tomcat, then load the page fresh.

Now I have heard of things like listeners that I can add to my submit buttons maybe to have this done on its own. Essentially I need that rich:tree to reload every time a submit button is pressed. Can someone give me a keyword that I should search for that I can research that will do what I need? It will be a great help to have a place to start with this, other than "listener"

Here is one of the pages if it helps, this page is a rich:tree on the left side, and then in the main content a set of tabs, one each for project, device and channel. Clicking on the rich:tree changes what is inside of each tab, and then from those tabs you can edit each individual entity.

How can I get my rich:tree(s) to register these changes and re load to reflect them after one of the submit buttons is pressed?

 
Matt Kohanek
Village Idiot
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I made some sort of progress...

I did this with my submit button:



the action sends the new data to the web service to be stored and works fine. The actionListener reloads the List of Objects bound to the tree with the new values, including the project update after this submit button has been pressed. This works too, I know because I used System.out code to make sure the new changes were being reflected.

Then I have the reRender attribute set to tree, which is the id of my rich:tree (rich:tree id="tree")

But when the submit button is pressed, it does everything, but I believe it is reRendering the tree BEFORE the actionListener completes. If I dont do anything, just hit that submit button a second time, the tree does get reRendered with the new data. So obviously everything is working, just not in the order I need it to.

So is there a way to tell my the commandButton, to first do the actionListener, which usually takes 3-5 seconds to run through completely, and then reRender the tree?

Or is there simply a better way to handle this?
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Matt, you're one busy little bee!

I think you need to study up on the JSF lifecycle so that you have a better grasp on what happens when, and in particular the difference between "normal" and "immediate" requests.

I don't think it's wise to mix actions and actionListeners in any event, although as far as it goes, I believe the official take is that the actionListeners include a built-in listener that fires the action handler (and I think it's always supposed to happen last).

In general, I think listeners are overused in JSF, and the only explanation I have for that is that I suspect that action handlers were a later addition to the architecture, so a lot of stale examples are out there polluting the Internet docs. At a minimum, I'll say that the early days of JSF were so volatile that for a long time, I'd despaired of ever being able to make sense of it (I got better). They do have their uses, of course. Especially if you need more than one action to be fired.

Normally, I'd update the tree datamodel in the "updateProject" method. In other words, have updateProject invoke reloadTree. To limit the display update, I'd attach the reRender to the commandButton element itself, and probably tack on an 'ajaxSingle="true"' just for good measure.
 
Matt Kohanek
Village Idiot
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm, I didnt think to combine the methods. Ill give that a try. I did try to put the reRender attribute on my commandButton at first, but it didn't seem to work. The method would run to fire the actionListener, which reLoaded the List with data(the list bound to the tree), and then the tree would flash which means it got reRendered, but it wasn't loading in the new List for some reason.

I have it working for now, but I am going to try your method. Thanks a lot

edit - Oh and Im busy because Im doing the work of three team members ha. Its not even worth trying to get them to do their part anymore, because it would take me longer to catch them up than to just do it myself. But this project officially ends in 4 days, at which point I pass this on to the company. Then I plan to use y knowledge Ive gained to start my own site, that will be used for trying out new things, and function as a sort of resume for when I graduate in May.
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Matt Kohanek wrote:Hmm, I didnt think to combine the methods. Ill give that a try. I did try to put the reRender attribute on my commandButton at first, but it didn't seem to work. The method would run to fire the actionListener, which reLoaded the List with data(the list bound to the tree), and then the tree would flash which means it got reRendered, but it wasn't loading in the new List for some reason.

I have it working for now, but I am going to try your method. Thanks a lot

edit - Oh and Im busy because Im doing the work of three team members ha. Its not even worth trying to get them to do their part anymore, because it would take me longer to catch them up than to just do it myself. But this project officially ends in 4 days, at which point I pass this on to the company. Then I plan to use y knowledge Ive gained to start my own site, that will be used for trying out new things, and function as a sort of resume for when I graduate in May.



I was going to ask you what kind of slacker you were to only be doing the work of 3 people in this day and age, but it looks like you're a student.

Oh the carefree, idle days of academy!
 
Matt Kohanek
Village Idiot
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, a student, but this project is actually for a worldwide company for their corporate website. There is a big design challenge at my school every year held by this company, and my proposal won so thats why Im doing this project. I say "my proposal", because all my teammates did was fill out their section of "The Team" on it hahaha. I guess I shouldve seen that as a sign of things to come
 
Don't touch me. And dont' touch this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic