Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would attach your own custom JSF validator to the red <code>&lt;h:inputText/&gt;</code></p> <pre><code>&lt;h:inputText value="#{var.red}" style="width:25px; text-align:right" maxlength="3"&gt; &lt;f:validator validatorId="rowValidator"/&gt; &lt;/inputText&gt; </code></pre> <p>Implement a JSF validator (since you're using Seam you can use the @Validator annotation).</p> <pre><code>@Validator public class RowValidator implements javax.faces.validator.Validator { public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { &lt;snip/&gt; } } </code></pre> <p>The key here is the UIComponent object passed to the <code>validate()</code> method. This is the <code>&lt;h:inputText/&gt;</code> you've bound the validator to. From here you can call <code>getParent()</code> to get the <code>&lt;h:inputText/&gt;</code> parent (<code>&lt;h:panelGrid/&gt;</code>). You can now enumerate the <code>&lt;h:panelGrid/&gt;</code> children objects to find the yellow <code>&lt;h:inputText/&gt;</code>, retrieve the value passed in to it and compare with the <code>value</code> parameter passed to the <code>validate()</code> method.</p> <p>If yellow is less than red you can do the following in your <code>validate()</code> method:</p> <pre><code>FacesMessage message = new FacesMessage(); message.setDetail("Yellow must be greater than red"); message.setSummary("Yellow must be greater than red"); message.setSeverity(FacesMessage.SEVERITY_ERROR); throw new ValidatorException(message); </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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