Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For the messages part, just display them all using <code>&lt;h:messages/&gt;</code> the usual way which you style as <code>list-style-type: decimal;</code>. That would display the numbers instead of bullets.</p> <p>Next step would be numbering the labels. This requires a bit more work as JSF doesn't provide any builtin facility to figure that. Basically you'll need to determine whether the label in question has a message associated or not and in which order the message has been enqueued. You could collect this information into a <code>Map&lt;String, String&gt;</code> as follows:</p> <pre><code>private Map&lt;String, String&gt; messageIndexes; public Map&lt;String, String&gt; getMessageIndexes() { FacesContext context = FacesContext.getCurrentInstance(); if (messageIndexes == null &amp;&amp; context.getRenderResponse()) { messageIndexes = new HashMap&lt;String, String&gt;(); Iterator&lt;String&gt; clientIds = context.getClientIdsWithMessages(); for (int i = 1; clientIds.hasNext(); i++) { messageIndexes.put(clientIds.next(), String.format("(%d)", i)); } } return messageIndexes; } </code></pre> <p>and then use it as follows:</p> <pre><code>&lt;h:form id="form"&gt; &lt;h:outputText value="#{bean.messageIndexes['form:input1']}" /&gt; &lt;h:outputLabel for="input1"&gt;Label 1&lt;/h:outputLabel&gt; &lt;h:inputText id="input1" value="#{bean.input1}" required="true" /&gt; &lt;br /&gt; &lt;h:outputText value="#{bean.messageIndexes['form:input2']}" /&gt; &lt;h:outputLabel for="input2"&gt;Label 2&lt;/h:outputLabel&gt; &lt;h:inputText id="input2" value="#{bean.input2}" required="true" /&gt; &lt;br /&gt; ... &lt;/h:form&gt; </code></pre> <p>If the client ID is not present in the map, then simply nothing will be rendered.</p> <p>To move all the job out of the bean, you may consider either a <code>PhaseListener</code> (do it in the <code>beforePhase()</code> of the <code>RENDER_RESPONSE</code>), or a custom label component.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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