Originally posted by Florian Fogl:
Hi everybody,
seems like I got stuck with this Problem here: I am trying to create HtmlCommandLink within my custom component that points to a method via method binding. My code looks as follows:
ResponseWriter writer = context.getResponseWriter();
HtmlForm htmlForm = new HtmlForm();
htmlForm.encodeBegin(getFacesContext());
HtmlCommandLink htmlCommandLink = new HtmlCommandLink();
htmlCommandLink.setParent(htmlForm);
MethodBinding methodBinding = getFacesContext().getApplication().createMethodBinding("#{TestAction.defaultAction}", null);
htmlCommandLink.setAction(methodBinding);
htmlCommandLink.encodeBegin(getFacesContext());
writer.write("Link");
htmlCommandLink.encodeEnd(getFacesContext());
htmlForm.encodeEnd(getFacesContext());
The Link is created in the page and I can click on it but the method is not invoked. I can invoke it in the code manually which means the reference to the method is working. Am I missing something here?
Any help appreciated
Florian
I guess u r missing one line:
htmlCommandLink.setId("put any id here");
For component created programatically,
JSF doesn't create the id automatically, you will have to set it up on ur own.