• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Implementing p:rating in a datatable column and passing the selected row id to the managed bean

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I would like to find out how can I implement a p:rating in a datatable column?
I am puzzled with passing the id of that particular object in a list to the managedbean.

<h:form>
<p:dataTable paginator ="true" paginatorAlwaysVisible="false" rows="10" first="0" paginatorPosition="bottom"
id="inbox" tableStyleClass="table table-stripped" var="message"
value="#{messagesManagedBean.allMessages}">

<p:column id="favColumn" headerText="Bookmark" sortBy="#{message.favorite}">
<p:rating value="#{messagesManagedBean.saveStar}" stars="1" styleClass="pull-left">
<p:ajax event="rate" listener="#{messagesManagedBean.onrate}" update="favColumn" />
<p:ajax event="cancel" listener="#{messagesManagedBean.oncancel}" update="favColumn" />
</p:rating>
</p:column>

</p:dataTable>
</h:form>
 
Saloon Keeper
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not familiar specifically with the IceFaces rating control, but the standard JSF paradigm is quite simple:

1. Use a DataModel instance for the dataTable's "value=" backing property (NOT a List, array or other POJO collection object - use the DataModel as a wrapper).
2. in the "onrate" listener, use the datamodel's "getRowData()" or "getRowIndex()" to determine which row is being updated.

I have no idea how "cancel" should work here, though. Or why one would be needed. Most controls of this nature are such that to "cancel" them, you'd either just re-click back to the original value or you'd use the "reset" control to restore the value(s) as of the (partial) page load.
reply
    Bookmark Topic Watch Topic
  • New Topic