File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Removing ID from JSF conversion error messages Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Removing ID from JSF conversion error messages" Watch "Removing ID from JSF conversion error messages" New topic
Author

Removing ID from JSF conversion error messages

Henry Chinaski
Greenhorn

Joined: May 26, 2011
Posts: 2
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

Joined: May 12, 2009
Posts: 218

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
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14571
    
    7

Just add a "converterMessage" attribute to your inputText element and you can display any message you like.


Customer surveys are for companies who didn't pay proper attention to begin with.
Henry Chinaski
Greenhorn

Joined: May 26, 2011
Posts: 2
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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Removing ID from JSF conversion error messages
 
Similar Threads
Apache Commons Validator: Working With Arrays
How to display custom message for inputText field of integer type
message required
Create a custom validation error message in JSF
display error message