voyent
how to create dynamic panel?  XML
Forum Index -> General Help
Author Message
maheshdudyala

Joined: 06/Apr/2011 08:46:39
Messages: 8
Offline


Hi

I have buuton.when i click on button new panel has to created dynamically.
That conatains close button.when i click on close button it has to be removed.
How can we achieve this?

Plz share any link related to this query?





Thanks
D.Mahesh Babu
edykory


Joined: 27/Nov/2006 00:00:00
Messages: 332
Offline


Ok, so in order to upset you:
1. Study some English
2. Study some JSF
3. Here is a little piece of info:

Although you could create JSF components programatically (in Java), it's not the usual way to do it.
Basically, to solve your problem, you would need to add an "action" or an "actionListener" method to your button, and switch on a flag on you controller.

Then, the panel that you want to appear dinamically needs a "rendered" attribute which depends on that flag on the controller. Finally, the "close" button needs an "action" or actionListener that switches off the "visible" flag.


So, to make it short:
Code:
<ice:form>
 bla bla bla
 
 <ice:commandButton value="Show panel" actionListener="#{myBean.showPanel}" disabled="#{myBean.panelVisible}" />
 
 </ice:form>
 
 <ice:panelGroup rendered="#{myBean.panelVisible}">
 <ice:form>
 bla bla bla bla
 <ice:commandButton value="Close" actionListener="#{myBean.hidePanel}" />
 /ice:form>
 </ice:panelGroup>




and your MyBean should have a field
Code:
private boolean panelVisible;
 

with getter and setter and the methods
Code:
public void showPanel(ActionEvent event) { 
     panelVisible = true;
 }
 
 public void hidePanel(ActionEvent event) {
     panelvisible = false;
 }
 


now, if all you need in the showPanel / hidePanel is to switch the flag (that is you don't need to populate some other fields, do some other business logic), then you can get rid of the methods and you buttons change into
Code:
<ice:commandButton value="Show panel">
     <f:setPropertyActionListener value="#{true}" target="#{myBean.panelVisible}" />
 </ice:commandButton>


If all you do is very "readonly" (you don't have other fields needing/failing validation) you can enclose all the code in just one form.

Good luck and study hard!

Eduard Korenschi



 
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team