wood burning stoves*
The moose likes JSF and the fly likes Error while displaying validation message for inputText generated dynamically in rich:dataTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Error while displaying validation message for inputText generated dynamically in rich:dataTable" Watch "Error while displaying validation message for inputText generated dynamically in rich:dataTable" New topic
Author

Error while displaying validation message for inputText generated dynamically in rich:dataTable

srikanth Thandra
Ranch Hand

Joined: Mar 04, 2009
Posts: 42

hi all,

A error is coming while displaying validation message of h:inputText generated dynamically under rich:dataTable. The code goes like below:

<rich:dataTable value="#{sessionScope.ChildsList}" var="child" rowKeyVar="currentRow">
<rich:column>
<hutputLabel value="ChildDisplayName">
</rich:column>
<rich:column>
<h:inputText id="ChildDisplayName_#{currentRow}" value="#{child.childDisplayName}" required="true" requiredMessage="Please Enter ChildDisplayName">
<h:message for="ChildDisplayName_#{currentRow}"/>
</rich:column>
</rich:dataTable>

Error is Unable to find component with id ChildDisplayName_1

Also how can we display message under inputText i.e. In rich:dataTable one row InputText next row validation message sholud come?

kindly post the solution as soon as possible


Thanx in advance,
Srikanth
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

You don't need to encode the row number in the control ID.

JSF already knows what row you're talking about, based on context. So just use the Id "ChildDisplayName" and don't attempt to add row ID to it.

Better yet, don't call it "ChildDisplayName". Names beginning with an uppercase letter should be classnames. For other objects, use lower case. Either camelCase or "child_display_name".


Customer surveys are for companies who didn't pay proper attention to begin with.
srikanth Thandra
Ranch Hand

Joined: Mar 04, 2009
Posts: 42

Thankx Tim for the reply,

But what if there are multiple inputTexts are there?
I have written that rich:dataTable takes value as sessionScope.ChildList. If this list contain multiple objects, say 2 objects for example.

So now dataTable displays two inputTexts. Now how can we display validation message corresponding to each inputText?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

The internally-generated IDs for each row in a dataTable display have the display row number encoded in them automatically. Generated references to the unencoded IDs will be converted by JSF to include that row number.

As long as the ID reference is made in the same row - like the 'lt;h:message for="controlid"/> element does - there's no problem. It's all automatic and you don't have to do anything.

One of the biggest problems people have with JSF is that they keep trying to add complicated stuff to do things that JSF was designed to make simple.
srikanth Thandra
Ranch Hand

Joined: Mar 04, 2009
Posts: 42


Thankx Tim,

Can we display the validation message under inputText component.

Right Now it is displaying side of inputText component

Sai Hegde
security forum advocate
Ranch Hand

Joined: Oct 26, 2010
Posts: 200
    
    1

Put them in a grid. h:PanelGrid and define columns = 1
Each element goes into the next row.
I think you could define it through a style element too.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error while displaying validation message for inputText generated dynamically in rich:dataTable