Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
srikanth Thandra
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".
 
srikanth Thandra
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 212
1
Android Flex Google App Engine
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic