Forums Register Login

Creating commandlinks at runtime

+Pie Number of slices to send: Send
Hi guys..how do i create a commandlink at runtime? i tried doing this:

FacesContext facesContext = FacesContext.getCurrentInstance();
Application application = facesContext.getApplication();


//UICommand output = (UICommand) application.createComponent("javax.faces.HtmlCommandLink");

UIOutput output = (UIOutput) application.createComponent("javax.faces.HtmlOutputLabel");

output.getAttributes().put("value","TEST DYNAMIC");
output.getAttributes().put("actionListener","#{PersonBean2.saveRecord}");
output.getAttributes().put("action","Ethan");

component.getChildren().add(output);


But it only works for outputLabels..i get a type mismatch error when i use it for commandLinks

Please help!
+Pie Number of slices to send: Send
I got it

it should be:
FacesContext facesContext = FacesContext.getCurrentInstance();
Application application = facesContext.getApplication();


UICommand output = (UICommand) application.createComponent("javax.faces.HtmlCommandLink");
output.setId("c1");
output.setValue("TESTING");

component.getChildren().add(output);
+Pie Number of slices to send: Send
I have another problem...

How do i create params at runtime, and assign them to dynamically created commandLink?


Ok, i was able to workaround this by creating a custom actionListener and assigning instances of that class to the dynamically created commandLink...
But,still, is there a way to create params at runtime?
[ April 18, 2006: Message edited by: JP Estrada ]
Oh. Hi guys! Look at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2019 times.
Similar Threads
dynamic JSF components question
problem in setting action to UICommand - HtmlCommandLink
problem in setting action to UICommand - HtmlCommandLink
problem in setting action to UICommand - HtmlCommandLink
Database grid tag
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 09:54:35.