Using straight jsf can you dynamicaly add aditional components to a form as the user inputs information? Such as they click button foo and button bar is rendered? Without the page reloading? With the page reloading?
There are different methods for handling this. You can create the component and set it's rendered property to false. Then in the backing bean when some event occurs you can change it's rendered property to true. This would all be done on the server side. There is no way of doing it without a page reload with JSF only.
You can also create components in your backing bean and then add them to the component tree when some event occurs. However, this is more complicated. I'd just go with the first option.
Originally posted by Daniel Prene: Would this generate ugly white space? Is there a way of using placeholders or somthing?
Ugly white space? No. When the HTML makes it to the browser the component isn't there at all. Well, no whitespace assuming your aren't absolutly placing html components on the page.
The best to way to figure out what you want to do is try a couple of different approaches and use the one that works best for your given situation. Got to dig in and get your hands dirty at some point.
Thanks for the help! You're right, it's time a boot up Eclipse and get busy. One last question though... we need to controll front-end layout and such, hence my question about placeholders. We need to know and controll exactly where somthing goes. I was just wondering if there was somthing for components like there is for validation errors. Thanks again!
I think you just have a misunderstanding of how it works. Let me explain. And this won't be accurate code, but just an example.
Ok, so that page gets requested as is. Here is the output
Now if we change the rendered property to true we get
So there is a placeholder. The placeholder exists where the component is defined in the JSP. It will show up where it should go as long as the rendered proeprty is set to true. It won't show up if set to false.
Side note: Obviously you'd want to use value binding for the rendered property rather than a static "true" or "false". [ July 18, 2005: Message edited by: Gregg Bolinger ]
From what I understand (not a whole lot yet), that's what the immediate="true" attribute does. There may be some extra code you need in the method that removes your components to get it to skip right to the redraw step without validating.