[ 
https://issues.apache.org/jira/browse/MYFACES-1729?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12531183
 ] 

Leonardo Uribe commented on MYFACES-1729:
-----------------------------------------

Hi

Based on this course of action

1. Change the way the validation messages are resolved to make similar as JSF 
RI (on render response phase). 

I have found a possible solution without implement f:loadBundle with state (if 
we do that, several incompatibilities with facelets arise. I have probed this 
and discard this solution). 

The idea is evaluate the label on HtmlMessageRenderer and HtmlMessagesRenderer. 
So, the loadBundle is registered before and the label value is available.

The idea is first resolve the data on Validators and Converters for example 
from this:

{2}: Validation Error: Specified attribute is not between the expected values 
of {0} and {1}.

to this

{0}: Validation Error: Specified attribute is not between the expected values 
of 10 and 50.

Then, on HtmlMessageRenderer and HtmlMessagesRenderer we resolve the label and 
get this:

LABEL: Validation Error: Specified attribute is not between the expected values 
of 10 and 50.

This is possible because we have a clientId of the owner of the message.

For do this we have to change all _MessageUtils.getLabel call to a simple "{0}" 
and change the implementations of getSummary and getDetail of
the renderer.

I provide a patch from on practice this solution.

Sounds good to me but I'm open to any suggestion, critic or improvement.



> label attribute does not resolve EL expresion (JSR 252 Issue 6 related)
> -----------------------------------------------------------------------
>
>                 Key: MYFACES-1729
>                 URL: https://issues.apache.org/jira/browse/MYFACES-1729
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-252
>    Affects Versions: 1.2.1-SNAPSHOT
>         Environment: Tomcat 6, Windows XP
>            Reporter: Leonardo Uribe
>         Attachments: patchLoadBundleWithoutImplementState.patch
>
>
> When validation is applied to the following page:
> <%@ page session="false" contentType="text/html;charset=utf-8"%>
> <%@ taglib uri="http://java.sun.com/jsf/html"; prefix="h"%>
> <%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f"%>
> <html>
> <f:view>
>       <[EMAIL PROTECTED] file="inc/head.inc"%>
>       <body>
>     <f:loadBundle 
> basename="org.apache.myfaces.examples.resource.example_messages" 
> var="example_messages"/>
>     <h1>Myfaces Examples JSF 1.2 Additions</h1>       
>         <h:messages id="messageList" styleClass="error"/>
>         <h:form id="form1">
>             <h:panelGrid columns="4">
>                 <h:outputLabel for="form1:number1"
>                     value="#{example_messages['sample1_number']} 1 :" />
>                 <h:outputText 
> value="#{validationController.number1ValidationLabel}" />
>                 <h:inputText label="#{example_messages['sample1_number']}" 
>                 id="number1" value="#{calcForm.number1}" maxlength="10"
>                     size="25" required="true">
>                     <f:validateLongRange minimum="1" maximum="10" />
>                 </h:inputText>
>                 <h:message id="number1Error" for="form1:number1" 
> styleClass="error" />
>             </h:panelGrid>
>             <h:panelGrid columns="4">
>                 <h:outputLabel for="form1:number2"
>                     value="#{example_messages['sample1_form']} 2 :" />
>                 <h:outputText 
> value="#{validationController.number2ValidationLabel}" />
>                 <h:inputText label="#{example_messages['sample1_form']}" 
>                     id="number2" value="#{calcForm.number2}" maxlength="10"
>                     size="25" required="true">
>                     <f:validateLongRange minimum="20" maximum="50" />
>                 </h:inputText>
>                 <h:message id="number2Error" for="form1:number2" 
> styleClass="error" />
>             </h:panelGrid>
>             <h:panelGrid columns="2">
>                 <h:outputLabel for="form1:result"
>                     value="#{example_messages['sample1_result']} :" />
>                 <h:outputText id="result" value="#{calcForm.result}" />
>             </h:panelGrid>
>             <h:panelGrid columns="4">
>                 <h:commandButton id="addButton"
>                     value="#{example_messages['sample1_add']}" action="none">
>                     <f:actionListener
>                         
> type="org.apache.myfaces.examples.example1.CalcActionListener"></f:actionListener>
>                 </h:commandButton>
>                 <h:commandButton id="subtractButton"
>                     value="#{example_messages['sample1_sub']}" action="none">
>                     <f:actionListener
>                         
> type="org.apache.myfaces.examples.example1.CalcActionListener"></f:actionListener>
>                 </h:commandButton>
>                 <h:commandLink id="href1" action="none">
>                     <h:outputText 
> value="#{example_messages['sample1_add_link']}" />
>                     <f:actionListener
>                         
> type="org.apache.myfaces.examples.example1.CalcActionListener"></f:actionListener>
>                 </h:commandLink>
>                 <h:commandLink id="href2" action="none">
>                     <h:outputText 
> value="#{example_messages['sample1_sub_link']}" />
>                     <f:actionListener
>                         
> type="org.apache.myfaces.examples.example1.CalcActionListener"></f:actionListener>
>                 </h:commandLink>
>             </h:panelGrid>
>         </h:form>
>       </body>
> </f:view>
> </html>
> If you use the attribute label on inputText like this:
>                 <h:inputText label="#{example_messages['sample1_number']}" 
>                 id="number1" value="#{calcForm.number1}" maxlength="10"
>                     size="25" required="true">
>                     <f:validateLongRange minimum="1" maximum="10" />
>                 </h:inputText>
> and a validation error happens, the EL expression inside label attribute 
> returns null. On a message box this looks like:
> null: Validation Error: Specified attribute is not between the expected 
> values of 20 and 50.
>  On JSF RI 1.2 this works correctly. null is replaced by the expression 
> inside the bundle.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to