You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by ToddP <tp...@NCR.COM> on 2006/06/16 23:41:52 UTC

Why is my DataModel being reset?

I posted this to users yesterday, but didn't get an answer. I figured it
might be a little too low level for that list. Apols if this is not the
right forum. With that said..

I have a vexing problem with a DataModel that I'm using within a bean.
Here's
the scenario:

I have a bean, let's called it Messages that encapsulates a ListDataModel.
That model is populated from a DB, and contains a set of Message objects. It
is used on a page to render out the data into a table:

<h:dataTable
       styleClass="standardTable"
       headerClass="tableHeader"
       rowClasses="standardRow1,standardRow2"
       columnClasses="severityColumn,messageColumn,timeColumn"
       id="message-table"
       var="message"
       value="#{messages.dataModel}"
     >

  <!--  Lay out our columns -->
<h:column id="message-column">

<f:facet name="msg-header">
<h:outputText id="msg-text" value="#{msg.message_header}" />
</f:facet>

<h:commandLink value="#{message.summaryText}" action="#{form.enableDetail}" 
               actionListener="#{messages.processAction}">
<f:param name="messageID" value="#{message.id}" />
</h:commandLink>
</h:column>
<snip>

You'll notice that the command links generated have an action and
actionListener associated with them. The intended use case is that when a
user clicks on one of the links in the main table, they are able to drill
down into the detailed view, and view the details of the particular message
they clicked on. Hence, form.enableDetail switches on detailed view, and the
message.id is used in the processAction method to identify which Message
object to display in the detailed view. 

The processAction method works just fine, in that it correctly retrieves the
message id, iterates through 
the DataModel and correctly leaves the model with rowIndex pointing at the
appropriate message. 

The problem I am having is when the page is rendered out, the rowIndex for
the DataModel has been reset to -1. In walking through the debugger I've
determined that this is happening in the UIData.broadcast() method. It would
appear that this method is attempting to reset the DataModel to the values
it contained when the FacesEvent that triggered the lifecycle started.

My question is, how do I stop that happening, or what is the approach I must
take to achieve the functionality I'm looking for?

Thanks

Todd
--
View this message in context: http://www.nabble.com/Why-is-my-DataModel-being-reset--t1800907.html#a4908469
Sent from the My Faces - Dev forum at Nabble.com.