Getting an updated data model selection
amitdk Jul 5, 2007 12:53 AMHello,
I have a JSF page that allows one of the dataTable columns to be updated. However the selected row update to certain elements of a row doesn't seem to come through in the DataModelSelection. Is the DataModel not updatable? I would imagine it would be - however I always get the old value back in my session bean.
Here's how the JSF page looks:
<h:form id="taskedit">
<a:log/>
<rich:panel>
<h1>Your Weekly Tasks:</h1>
<h:outputText value="No tasks added for this week" rendered="#{weeklyTasks.rowCount==0}"/>
<rich:dataTable value="#{weeklyTasks}"
var="wtask" rendered="#{weeklyTasks.rowCount>0}"
onRowMouseOver="this.style.backgroundColor='#E0E0E0'"
onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
<a:support event="onRowDblClick" action="#{report.updateTask}" reRender="taskedit"/>
<rich:column rendered="#{not report.taskEditable}">
<f:facet name="header">Assigned Task</f:facet>
<h:outputText value="#{wtask.comments}"/>
</rich:column>
<rich:column rendered="#{report.taskEditable}">
<f:facet name="header">Assigned Task</f:facet>
<h:inputTextarea rows="5" cols="80" value="#{wtask.comments}"/>
</rich:column>
<rich:column>
<f:facet name="header">action</f:facet>
<s:button action="#{report.saveTask}" value="Save Task" />
</rich:column>
<rich:column>
<f:facet name="header">action</f:facet>
<s:button action="#{report.removeTask}" value="Remove Task" />
</rich:column>
</rich:dataTable>
</rich:panel>
</h:form>
Here's how the session bean looks:
@Stateful
@Name("report")
@Scope(ScopeType.SESSION)
public class ReportBean implements Report, Serializable
{
private static final long serialVersionUID = 8545529442081579216L;
@PersistenceContext(type = PersistenceContextType.EXTENDED)
EntityManager entityMgr;
@In
User user;
@DataModel
List<TaskAssignment> weeklyTasks;
@DataModelSelection
private TaskAssignment selectedTask;
.............
@Factory("weeklyTasks")
public void showTasks()
{
weeklyTasks = entityMgr
.createQuery(......).setParameter(..).getResultList();
}
// Here's the method I expect to get the updated comments
public void saveTask()
{
System.out.println( selectedTask.getComments() );
.............
}
On a double click on a row on the dataTable, the comments field becomes editable, however the submit and corresponding invocation of saveTask does not give me the latest edited value.
Is there something I am missing here in terms of how you capture an edited row value?
Any help is appreciated.
Thanks
Amit Karandikar