Note that there are some explanatory texts on larger screens.

plurals
  1. POShowing the JSF Error Messages
    text
    copied!<p>I am using JSF Myfaces Impl 1.2 without tomahawk and other libs :</p> <p>I am using different styles + images to show JSF Error messages, find below a sample.</p> <pre><code>&lt;h:panelGroup rendered="${adminBean.showErrorIcon==2}"&gt; &lt;table width="375" align="center" class="InfoMsg" border="1" cellspacing="0" cellpadding="0"&gt; &lt;tr&gt; &lt;td&gt; &lt;table width="375" align="center" class="InfoMsg" border="0"&gt; &lt;tr&gt; &lt;td width="50"&gt;&lt;img src="static/images/info_icon.gif" width="40" height="40" border="0" /&gt;&lt;/td&gt; &lt;td width="325" align="left"&gt;&lt;h:messages layout="table" errorClass="InfoMsg" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p></p> <p>Based on the int variable of the Backing Bean , I am displaying a diff image and the corresponding FacesMessage(s) in the screen - only 2 cases - error or an information.</p> <p>I am using the below code to set the variable of the Backing Bean </p> <pre><code>//Checking if there are messages! log.debug("Checking if there are messages to be shown ]"); if(getShowErrorIcon()==99){//Set only if the value is still the default : log.debug("getShowErrorIcon was DEFAULT - Changing it ]"); Iterator&lt;FacesMessage&gt; messages = FacesContext.getCurrentInstance().getMessages(); if(messages != null &amp;&amp; getShowErrorIcon()==99){//Set Error/Info for messages that are not added here : while(messages.hasNext()){ log.debug("There are ***messages***"); FacesMessage aMessage =(FacesMessage) messages.next(); if(aMessage.getSeverity().compareTo(FacesMessage.SEVERITY_ERROR)==0){ setShowErrorIcon(1); break;//just once is enough } if(aMessage.getSeverity().compareTo(FacesMessage.SEVERITY_INFO)==0){ setShowErrorIcon(2); break; } } } }//if it is not default, then something has been set already, why again? </code></pre> <p>Now the problem I have is , There are FacesMessage(s) that are added by the MyFacesImpl - like the required=true and the custom validator messages which are added during PROCESS_VALIDATION Phase, These are not shown in the screen since my integer variable of the Backing Bean is not set , and since the INVOKE_APPLICATION Phase was not called (and that means the above code was not called!!!) </p> <p>How do I resolve this? Or Whats the best way / Where's the best place to place the above checking code ?</p> <p>Appreciate your help.Thanks!</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