You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Mike Kienenberger <mk...@gmail.com> on 2010/06/17 22:21:35 UTC

Re: [tomahawk] replaceIdWithLabel not working in t:messages after update to JSF 1.2

I finally had some time to investigate this.

The problem appears to be that in Tomahawk 1.1.9, t:messages renderer
returns the id rather than the clientId of the component.  This is
exactly the opposite of what Michael Heinen found in his original
message.   Unfortunately it means that only the last piece of the
clientId is replaced in the message, rather than the entire client id.


    public static String findInputId(FacesContext facesContext, String
inputClientId)

[...]

        return info==null?null:(info.getForComponent()==null?null:info.getForComponent().getId());

Can anyone think of a reason why we would be returning the Id instead
of the clientId?   Can anyone think of a use case where the generated
message would be using the Id instead of the client id?   My limited
testing shows that the client-id is used in the FacesMessages.




On Fri, Apr 2, 2010 at 1:43 PM, Mike Kienenberger <mk...@gmail.com> wrote:
> Michael, I'm having the same problem you had before using
>
> myfaces-api-1.2.8.jar
> tomahawk-1.1.9.jar
>
> Were you saying it was caused by a patch you made, or by an incorrect
> patch MyFaces incorrectly applied?
>
> This page code:
> -----------------------------------------------
>                                        <t:messages
>                                         globalOnly="true"
>                                         showDetail="true" />
>
>                                        <t:messages
>                                         globalOnly="false"
>                                         showDetail="true" />
>
>                                                <h:outputLabel for="accountPaymentAmountInput"
>                                                        value="Amount" />
>                                                <h:inputText id="accountPaymentAmountInput"
>                                                        binding="#{page.accountPaymentAmountInput}"
>                                                        required="true"
>                                                        value="#{page.accountPaymentAmount}">
>                                                </h:inputText>
> -----------------------------------------------
>
> results in
>
> ========================
> masterForm:enterPaymentForm:Amount: Validation Error: Value is required.
> ========================
>
>
> On Tue, Dec 22, 2009 at 12:49 PM, Michael Heinen
> <mi...@recommind.com> wrote:
>> I found the issue during the creation of a small test project.
>> It was caused by a not correctly migrated patch for the UIInput.class.
>>
>> Michael
>>
>> -----Original Message-----
>> From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On Behalf Of Jakob Korherr
>> Sent: Dienstag, 22. Dezember 2009 17:05
>> To: MyFaces Discussion
>> Subject: Re: [tomahawk] replaceIdWithLabel not working in t:messages after update to JSF 1.2
>>
>> Hi Michael,
>>
>> I'm sorry, but I can not reproduce your problem. On my machine it is "User:
>> Validierungsfehler: Eingabe erforderlich.".
>>
>> Can you please provide more information about your jsp.
>>
>> Regards,
>> Jakob
>>
>>
>> 2009/12/22 Michael Heinen <mi...@recommind.com>
>>
>>> Hi,
>>>
>>> I have another migration issue:
>>> Error messages are rendered with the component ids instead of the label
>>> after update from myfaces 1.1.6 to 1.2.8 and tomahawk to 12_1.1.9
>>>
>>> jsp:
>>> <h:outputLabel for="name" value="User"/>
>>> <h:panelGroup>
>>>  <h:inputText id="name" value="#{MyController.name}" required="true">
>>>
>>> Class
>>> org.apache.myfaces.renderkit.html.ext.HtmlMessagesRenderer.getSummary(...)
>>> contains following line (86):
>>>
>>> msgSummary =
>>> msgSummary.replaceAll(HtmlMessageRenderer.findInputId(facesContext,
>>> msgClientId),inputLabel);
>>>
>>> Content:
>>> msgSummary= name: Validierungsfehler: Eingabe erforderlich.
>>> HtmlMessageRenderer.findInputId(facesContext, msgClientId) returns
>>> loginForm:name
>>> inptutLabel= User
>>>
>>> So the problem is that findInputId returns the full qualified clientid
>>> instead of the id.
>>> This worked with the old 1.1 jars.
>>>
>>> Any ideas?
>>> Michael
>>>
>>
>

Re: [tomahawk] replaceIdWithLabel not working in t:messages after update to JSF 1.2

Posted by Mike Kienenberger <mk...@gmail.com>.
Ok.  And to close this out, the problem is that I was using
tomahawk-1.1.9 instead of tomahawk-1.2-1.1.9.

In 1.2-1.1.9, the problem has been solved by returning either the
clientId or the Id as appropriate.   I guess it's possible that
there's still a bug in 1.1's 1.1.9, but until someone brings it up, I
guess we'll leave it alone.


On Thu, Jun 17, 2010 at 4:30 PM, Mike Kienenberger <mk...@gmail.com> wrote:
> Maybe the solution is to use
>
>            msgSummary =
> msgSummary.replaceAll(HtmlMessageRenderer.findInputId(msgClientId,
> inputLabel);
>
> in addition to
>
>            msgSummary =
> msgSummary.replaceAll(HtmlMessageRenderer.findInputId(facesContext,
> msgClientId),inputLabel);
>
> So on the first pass, replace the full client-id.
> On the second pass, replace the id.
>
> I'm still not certain why we'd replace only the Id, but this should
> provide backwards-compatible behavior.
>
> I still think the right fix is to use only the client-id, but there
> must be a reason why someone went to great lengths to look up the Id
> from the client-id.
>
>
> On Thu, Jun 17, 2010 at 4:21 PM, Mike Kienenberger <mk...@gmail.com> wrote:
>> I finally had some time to investigate this.
>>
>> The problem appears to be that in Tomahawk 1.1.9, t:messages renderer
>> returns the id rather than the clientId of the component.  This is
>> exactly the opposite of what Michael Heinen found in his original
>> message.   Unfortunately it means that only the last piece of the
>> clientId is replaced in the message, rather than the entire client id.
>>
>>
>>    public static String findInputId(FacesContext facesContext, String
>> inputClientId)
>>
>> [...]
>>
>>        return info==null?null:(info.getForComponent()==null?null:info.getForComponent().getId());
>>
>> Can anyone think of a reason why we would be returning the Id instead
>> of the clientId?   Can anyone think of a use case where the generated
>> message would be using the Id instead of the client id?   My limited
>> testing shows that the client-id is used in the FacesMessages.
>>
>>
>>
>>
>> On Fri, Apr 2, 2010 at 1:43 PM, Mike Kienenberger <mk...@gmail.com> wrote:
>>> Michael, I'm having the same problem you had before using
>>>
>>> myfaces-api-1.2.8.jar
>>> tomahawk-1.1.9.jar
>>>
>>> Were you saying it was caused by a patch you made, or by an incorrect
>>> patch MyFaces incorrectly applied?
>>>
>>> This page code:
>>> -----------------------------------------------
>>>                                        <t:messages
>>>                                         globalOnly="true"
>>>                                         showDetail="true" />
>>>
>>>                                        <t:messages
>>>                                         globalOnly="false"
>>>                                         showDetail="true" />
>>>
>>>                                                <h:outputLabel for="accountPaymentAmountInput"
>>>                                                        value="Amount" />
>>>                                                <h:inputText id="accountPaymentAmountInput"
>>>                                                        binding="#{page.accountPaymentAmountInput}"
>>>                                                        required="true"
>>>                                                        value="#{page.accountPaymentAmount}">
>>>                                                </h:inputText>
>>> -----------------------------------------------
>>>
>>> results in
>>>
>>> ========================
>>> masterForm:enterPaymentForm:Amount: Validation Error: Value is required.
>>> ========================
>>>
>>>
>>> On Tue, Dec 22, 2009 at 12:49 PM, Michael Heinen
>>> <mi...@recommind.com> wrote:
>>>> I found the issue during the creation of a small test project.
>>>> It was caused by a not correctly migrated patch for the UIInput.class.
>>>>
>>>> Michael
>>>>
>>>> -----Original Message-----
>>>> From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On Behalf Of Jakob Korherr
>>>> Sent: Dienstag, 22. Dezember 2009 17:05
>>>> To: MyFaces Discussion
>>>> Subject: Re: [tomahawk] replaceIdWithLabel not working in t:messages after update to JSF 1.2
>>>>
>>>> Hi Michael,
>>>>
>>>> I'm sorry, but I can not reproduce your problem. On my machine it is "User:
>>>> Validierungsfehler: Eingabe erforderlich.".
>>>>
>>>> Can you please provide more information about your jsp.
>>>>
>>>> Regards,
>>>> Jakob
>>>>
>>>>
>>>> 2009/12/22 Michael Heinen <mi...@recommind.com>
>>>>
>>>>> Hi,
>>>>>
>>>>> I have another migration issue:
>>>>> Error messages are rendered with the component ids instead of the label
>>>>> after update from myfaces 1.1.6 to 1.2.8 and tomahawk to 12_1.1.9
>>>>>
>>>>> jsp:
>>>>> <h:outputLabel for="name" value="User"/>
>>>>> <h:panelGroup>
>>>>>  <h:inputText id="name" value="#{MyController.name}" required="true">
>>>>>
>>>>> Class
>>>>> org.apache.myfaces.renderkit.html.ext.HtmlMessagesRenderer.getSummary(...)
>>>>> contains following line (86):
>>>>>
>>>>> msgSummary =
>>>>> msgSummary.replaceAll(HtmlMessageRenderer.findInputId(facesContext,
>>>>> msgClientId),inputLabel);
>>>>>
>>>>> Content:
>>>>> msgSummary= name: Validierungsfehler: Eingabe erforderlich.
>>>>> HtmlMessageRenderer.findInputId(facesContext, msgClientId) returns
>>>>> loginForm:name
>>>>> inptutLabel= User
>>>>>
>>>>> So the problem is that findInputId returns the full qualified clientid
>>>>> instead of the id.
>>>>> This worked with the old 1.1 jars.
>>>>>
>>>>> Any ideas?
>>>>> Michael
>>>>>
>>>>
>>>
>>
>

Re: [tomahawk] replaceIdWithLabel not working in t:messages after update to JSF 1.2

Posted by Mike Kienenberger <mk...@gmail.com>.
Maybe the solution is to use

            msgSummary =
msgSummary.replaceAll(HtmlMessageRenderer.findInputId(msgClientId,
inputLabel);

in addition to

            msgSummary =
msgSummary.replaceAll(HtmlMessageRenderer.findInputId(facesContext,
msgClientId),inputLabel);

So on the first pass, replace the full client-id.
On the second pass, replace the id.

I'm still not certain why we'd replace only the Id, but this should
provide backwards-compatible behavior.

I still think the right fix is to use only the client-id, but there
must be a reason why someone went to great lengths to look up the Id
from the client-id.


On Thu, Jun 17, 2010 at 4:21 PM, Mike Kienenberger <mk...@gmail.com> wrote:
> I finally had some time to investigate this.
>
> The problem appears to be that in Tomahawk 1.1.9, t:messages renderer
> returns the id rather than the clientId of the component.  This is
> exactly the opposite of what Michael Heinen found in his original
> message.   Unfortunately it means that only the last piece of the
> clientId is replaced in the message, rather than the entire client id.
>
>
>    public static String findInputId(FacesContext facesContext, String
> inputClientId)
>
> [...]
>
>        return info==null?null:(info.getForComponent()==null?null:info.getForComponent().getId());
>
> Can anyone think of a reason why we would be returning the Id instead
> of the clientId?   Can anyone think of a use case where the generated
> message would be using the Id instead of the client id?   My limited
> testing shows that the client-id is used in the FacesMessages.
>
>
>
>
> On Fri, Apr 2, 2010 at 1:43 PM, Mike Kienenberger <mk...@gmail.com> wrote:
>> Michael, I'm having the same problem you had before using
>>
>> myfaces-api-1.2.8.jar
>> tomahawk-1.1.9.jar
>>
>> Were you saying it was caused by a patch you made, or by an incorrect
>> patch MyFaces incorrectly applied?
>>
>> This page code:
>> -----------------------------------------------
>>                                        <t:messages
>>                                         globalOnly="true"
>>                                         showDetail="true" />
>>
>>                                        <t:messages
>>                                         globalOnly="false"
>>                                         showDetail="true" />
>>
>>                                                <h:outputLabel for="accountPaymentAmountInput"
>>                                                        value="Amount" />
>>                                                <h:inputText id="accountPaymentAmountInput"
>>                                                        binding="#{page.accountPaymentAmountInput}"
>>                                                        required="true"
>>                                                        value="#{page.accountPaymentAmount}">
>>                                                </h:inputText>
>> -----------------------------------------------
>>
>> results in
>>
>> ========================
>> masterForm:enterPaymentForm:Amount: Validation Error: Value is required.
>> ========================
>>
>>
>> On Tue, Dec 22, 2009 at 12:49 PM, Michael Heinen
>> <mi...@recommind.com> wrote:
>>> I found the issue during the creation of a small test project.
>>> It was caused by a not correctly migrated patch for the UIInput.class.
>>>
>>> Michael
>>>
>>> -----Original Message-----
>>> From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On Behalf Of Jakob Korherr
>>> Sent: Dienstag, 22. Dezember 2009 17:05
>>> To: MyFaces Discussion
>>> Subject: Re: [tomahawk] replaceIdWithLabel not working in t:messages after update to JSF 1.2
>>>
>>> Hi Michael,
>>>
>>> I'm sorry, but I can not reproduce your problem. On my machine it is "User:
>>> Validierungsfehler: Eingabe erforderlich.".
>>>
>>> Can you please provide more information about your jsp.
>>>
>>> Regards,
>>> Jakob
>>>
>>>
>>> 2009/12/22 Michael Heinen <mi...@recommind.com>
>>>
>>>> Hi,
>>>>
>>>> I have another migration issue:
>>>> Error messages are rendered with the component ids instead of the label
>>>> after update from myfaces 1.1.6 to 1.2.8 and tomahawk to 12_1.1.9
>>>>
>>>> jsp:
>>>> <h:outputLabel for="name" value="User"/>
>>>> <h:panelGroup>
>>>>  <h:inputText id="name" value="#{MyController.name}" required="true">
>>>>
>>>> Class
>>>> org.apache.myfaces.renderkit.html.ext.HtmlMessagesRenderer.getSummary(...)
>>>> contains following line (86):
>>>>
>>>> msgSummary =
>>>> msgSummary.replaceAll(HtmlMessageRenderer.findInputId(facesContext,
>>>> msgClientId),inputLabel);
>>>>
>>>> Content:
>>>> msgSummary= name: Validierungsfehler: Eingabe erforderlich.
>>>> HtmlMessageRenderer.findInputId(facesContext, msgClientId) returns
>>>> loginForm:name
>>>> inptutLabel= User
>>>>
>>>> So the problem is that findInputId returns the full qualified clientid
>>>> instead of the id.
>>>> This worked with the old 1.1 jars.
>>>>
>>>> Any ideas?
>>>> Michael
>>>>
>>>
>>
>