Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Removing ID from JSF conversion error messages  RSS feed

 
Henry Chinaski
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This seems like a simple issue but I can't seem to find the answer in the documentation or the forums. Forgive me if I'm missing something obvious.

I am using JSF2 and have an inputText like this inside a nested table. This is a simplified example but should illustrate the issue.

<ui:repeat value="#{bean.these}" var="item">
... some HTML
<ui:repeat value="#{item.products}" var="product">
... some HTML
<h:inputText id="editQuantity" class="editQuantity" style="width:25px" value="#{product.quantity}">
<f:convertNumber pattern="#,##0.0#"/>
</h:inputText>
<h:message for="editQuantity" errorClass="my-error-text" />
</ui:repeat>
</ui:repeat>

In my form if I enter invalid input such as "x" I get this validation error message:

lsform:j_idt129:0:j_idt133:0:j_idt140:0:editQuantity: 'x' is not a number pattern. Example: #,##0.0#

The "lsform:j_idt129:0:j_idt133:0:j_idt140:0:editQuantity:" is not meaningful to the user so I would like to suppress this part of the message. I am fine with the "'x' is not a number pattern. Example: #,##0.0#" part of the message.

I see forum posts describing how to install custom validation messages by overriding the values found in Messages.properties. However that only changes the 2nd half of the message, I need to suppress the first half.

I have tried adding an id or label attribute to the h:message and various things along these lines but cannot seem to affect this part of the message.

Thank you for any information.

H.C.
 
Brendan Healey
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi, have a little play around with h:message showSummary="true/false" showDetail="true/false"
and see if this helps. I'm not sure why I don't have the same problem without having to specify
these attributes, there must be some global setting.

Regards,
Brendan.
 
Tim Holloway
Bartender
Posts: 18709
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just add a "converterMessage" attribute to your inputText element and you can display any message you like.
 
Henry Chinaski
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, converterMessage helps. Coding the message in the xhtml page means that I can't use the message defined in the properties file though. I'll look at ways to get that into the page via EL.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!