Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think the problem you encounter is due to the way you add the commandButton in the JSF component tree, or, to be more exact, the way uou do NOT add it in the component tree.</p> <p>As you do not attach the commandButton to the JSF component tree, when this component is rendered (by your call to .encodeAll() method), it does not find the form where this component is nested. Thus, the HTML input is not created correctly.</p> <p>Maybe you can try to add the commandButton created to the form directly, before asking it to be rendered. You can do that with the following code:</p> <pre><code>// Search for the component HtmlForm that is a (in)direct parent of the current component private UIComponent getCurrentForm(UIComponent currentComponent) { UIComponent parent = currentComponent.getParent(); while ((parent != null) &amp;&amp; !(parent instanceof HtmlForm)) { parent = parent.getParent(); } return parent; } public void encodeBegin(FacesContext context) throws IOException { ... HtmlAjaxCommandButton replyCommentButton = new HtmlAjaxCommandButton(); ... // Add the command button in the form that contains your custom component... UIComponent form = getCurrentForm(this); if (form != null) { form.getChildren().add(replyCommentButton); } replyCommentButton.encodeAll(context); ... } </code></pre> <p><em>note that I've tested this code, so maybe you have to modify it a little...</em></p> <p>If it still doesn't work, maybe you will need to review you code in order to create the commandButton outside the render class or outside the encodeBegin... I don't think it is a good idea to modify the JSF components tree during the rendering phase...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload