Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You need to ensure that your custom component class extends <a href="http://download.oracle.com/javaee/6/api/javax/faces/component/UIInput.html" rel="nofollow noreferrer"><code>UIInput</code></a> and that you're in the <a href="http://download.oracle.com/javaee/6/api/javax/faces/render/Renderer.html#encodeEnd%28javax.faces.context.FacesContext,%20javax.faces.component.UIComponent%29" rel="nofollow noreferrer"><code>encodeEnd()</code></a> method of your renderer writing the component's client ID as <code>name</code> attribute of the HTML input element. Then you can in the overriden <a href="http://download.oracle.com/javaee/6/api/javax/faces/render/Renderer.html#decode%28javax.faces.context.FacesContext,%20javax.faces.component.UIComponent%29" rel="nofollow noreferrer"><code>decode()</code></a> method of your renderer just grab the submitted value from the request parameter map with the component's client ID as parameter name and set it as <a href="http://download.oracle.com/javaee/6/api/javax/faces/component/UIInput.html#setSubmittedValue%28java.lang.Object%29" rel="nofollow noreferrer"><code>UIInput#setSubmittedValue()</code></a> and let JSF do the remnant of the job of converting, validating and updating the model value.</p> <pre><code>@Override public void decode(FacesContext context, UIComponent component) { // Do if necessary first validation on disabled="true" or readonly="true", if any. // Then just get the submitted value by client ID as name. String clientId = component.getClientId(context); String submittedValue = context.getExternalContext().getRequestParameterMap().get(clientId); ((UIInput) component).setSubmittedValue(submittedValue); } </code></pre> <hr> <p><strong>Unrelated</strong> to the concrete problem, are you aware of the new composite component support in JSP's successor Facelets? I have the impression that you don't necessarily need a custom component for this purpose. Or are you really restricted to using the legacy JSP as view technology in spite of that you're already on JSF 2.x? See also <a href="https://stackoverflow.com/questions/6822000/when-to-use-uiinclude-tag-files-composite-components-and-or-custom-component">When to use &lt;ui:include&gt;, tag files, composite components and/or custom components?</a></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