• 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

Changing a component's properties from a bean

 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do you change a component's properties from a bean?

What I want to do: Use a listbox's onchange to hide and show panelGrids.


Thank you in advance (atleast for reading this post),
-Dan
[ July 19, 2005: Message edited by: Daniel Prene ]
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are 2 ways. Both work well. Both will happen in the change listener method you've defined for the listbox.

1. create boolean properties for the rendered attribute of the panels. On the change event make these boolean properties true/false accordingly. Example:





2. Bind the html component with a faces component in the backing bean and then modify the components rendered property. Example:





I don't know how syntactically correct some of the code is as I am not on my normal PC today. However, the concept is correct. Hope that helps.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FYI - works the same for panelGrid or any component for that matter. My fingers just typed panelGroup.
 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. You're solution works wonderfully... but is there a way to negate having to add the name in three diferent places everytime a new item/group is coded? We want the front-end guys out of the back-end code and vesa-versa
Thank you once again,
-Dan
 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I coded the following bean in an atempt to solve these problems, but am still clueless on how it fits in:
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Daniel Prene:
Thank you. You're solution works wonderfully... but is there a way to negate having to add the name in three diferent places everytime a new item/group is coded? We want the front-end guys out of the back-end code and vesa-versa
Thank you once again,
-Dan



No, not really. Technically, the front end guys should also be coding the backing beans. Your so called backend guys should be coding all the grunt work that the backing beans use (utility classes, services, DAO, etc).
 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so there's no way of the rendered variable using the value returned by checkRender?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Daniel Prene:
so there's no way of the rendered variable using the value returned by checkRender?



Not sure what you mean by that.
 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do the valid equivelent to this:



^using the code I posted earlyer

The above is just a concept sketch of what I want to do.
[ July 19, 2005: Message edited by: Daniel Prene ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, you can't do that. It's because of how JSF and the JavaBean spec work together.
 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gah! That's rather discouraging... I had hoped JSF would support encapsulation better then this... Alright, thank you endlessly though, you helped me unbeleivably today.

Your humble servent,
-D.P.
 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Erhm. I guess what I wanted to do wasn't imposible:





Although, I'm having trouble with white space and such... I've also tried subview and panelgroup, but so far panelgrid has been the cleanest (I just don't add <br>) I'm guessing that the html is rendered before faces? but the white space apears even if another component is rendered... Any thoughts?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I forgot about just using an expression. Good job!

As far as the whitespaces, not sure. Where are the white spaces in the HTML? Can you maybe post a screenshot of what you are talking about after the page gets rendered?
 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to change the subject of these posts to somthing more appropriate?
[ July 20, 2005: Message edited by: Daniel Prene ]
 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll start with my panelGroup atempt...

problem: The <br>s from within the panelGroup move to above every panelGroup

included code for panelGroup foo:



html output:
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try doing this instead for your br tags:



The verbatim tag is used so that JSF knows you want this specific HTML code positioned where you coded them. Otherwise, JSF takes straight HTML and just kind of puts all together in one place. Goofy, but noone said JSF is perfect.
 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you once again oh great master of knowledge. I think I may combine all that I've learned here and form a tutorial...

My next goal is to move the panelGroups completely out of the form code... may sound funky but that's what the boss wants... Wish me luck... I'm going to need it! Another question though... is what he wants even possible?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Daniel Prene:
Thank you once again oh great master of knowledge. I think I may combine all that I've learned here and form a tutorial...

My next goal is to move the panelGroups completely out of the form code... may sound funky but that's what the boss wants... Wish me luck... I'm going to need it! Another question though... is what he wants even possible?



Sure, you don't ever have to use panelGroups or panelGrids. It sure makes laying things out easier. But they aren't required for anything.
 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but we still need to be able to turn chunks of code on or off when an item is selected
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Daniel Prene:
but we still need to be able to turn chunks of code on or off when an item is selected



That is correct. And now you would have to use the rendered property on each component. You just asked if it was possible.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic