• Post Reply Bookmark Topic Watch Topic
  • New Topic

Display Dynamic Checkbox in <rich:datatable and based on user selection rendered TextArea  RSS feed

 
Khushwant patidar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi I am attaching my code, My problem i si am getting a list from the database and i am dispalying on the UI in a datatable with only checkbox.

Once user will select any of the check box then i need to renderedd on text area for that checkbox. So checkbox and textarea will be dynamic.

I have written some code in bean also but that is not working for first object it is working fine but for remaining object it is not workinhg please help to resolve problem


<rich:dataTable width="100%" id="searchResult" border="0"
rowKeyVar="rowKey"
value="#{rsmRiskProfileBean.sharedGovtAgencyList}" var="item"
headerClass="head" cellpadding="2"
rowClasses="odd,even" cellspacing="0" bgcolor="#FFFFFF" >


<rich:column style="text-align:center; background-color:#FFFFFF" width="1%">
<h:selectBooleanCheckbox id="khudh" value="#{item.selected}"
immediate="true" >

<a4j:support event="onchange" action="#{rsmRiskProfileBean.addSharedMessage}" reRender="committeemenbersname" >
<!--<f:setPropertyActionListener value="#{item.documentName}" target="#{rsmRiskProfileBean.sharedGovtAgency}" />
--></a4j:support>
</h:selectBooleanCheckbox>
</rich:column>

<rich:column style="background-color:#FFFFFF" id="committeemenbersname" >
<h:outputText value="#{item.documentName}" />
<rich:separator lineType="none" />
<h:inputTextarea id="shareProfileComment" rows="2" cols="45" rendered="#{rsmRiskProfileBean.isSharedMessageRendered}" >
<f:validateLength maximum="200" />
</h:inputTextarea>

<!-- <a4j:outputPanel id="committeeValueNoMessage2">
<h:message for="committeeValueid2" errorClass="error-message"
id="committeeValueidOutputPanel2" />
</a4j:outputPanel> -->
</rich:column>

</rich:dataTable>









public void addSharedMessage()
{

for(DocumentTypeDTO documentTypeDTO1 : shareGovtAgencyList)
{
System.out.println(documentTypeDTO1.getSelected());
if( documentTypeDTO1.getSelected())
{
this.setSharedMessageRendered(true);
setSharedMessageRendered(true);

}else
{
this.setSharedMessageRendered(false);

}
}
}

 
Tim Holloway
Bartender
Posts: 18663
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Khushwant!

You can make your pre-formatted Java and XML easier to read if you use "Code" tags to wrap them. We have a button on our message editor for that.

It looks like you are binding your List directly to the dataTable. The List doesn't contain the necessary JSF context information that tells JSF which row of the List you are working with.

If you construct a property of type ListDataModel in your backing bean and use that object to wrap the actual List, it will provide the necessary context (note that you must have View Scope or greater on the bean that holds the ListDataModel).

When your AJAX method is fired, it can then use the currentRow or rowIndex method of that DataModel object to determine the row that the user has selected.

 
Khushwant patidar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi thanks for your suggestion and your reply.
As you already understand that i am new in jsf and i am not much aware with ListDataModel, we are using ListDataModel while searching record.

How to use it for UI i am not getting, you are right i am directly displaying list, and the boolean value is also not setting in my pojo object object.

Please help to resolve i am stuck here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!