Bruno's idea of using a listener worked great, thanks Bruno!  
Here's the relevant code in case anyone else wants to do something similar:

VIEW:
<x:dataTable id="params_dt" value="#{scriptHandler.parameterModel}" 
        var="params" rowIndexVar="indexParams">
        <h:column id="params_col"> 
                <h:inputText id="params_it" value="#{params.value}" 
        
valueChangeListener="#{scriptHandler.updateParamValue}">
                        <f:param name="index" value="#{indexParams}"/>
                </h:inputText>
        </h:column>
</x:dataTable>

CONTROLLER(scripthandler.updateParamValue()):

public void updateParamValue(ValueChangeEvent vce){
        
        String newValue = (String) vce.getNewValue();
        
        // get new value from inputText box
        UIParameter inputBox = (UIParameter)
vce.getComponent().getChildren().get(0);
        Integer index = (Integer) inputBox.getValue();
        
      //update the model with the new value.
        changeParameterModelValue(index, newValue);
           
    }


public void changeParameterModelValue(Integer newIndex, String newValue){
                 
                ArrayList parameterArray;
                int index = newIndex.intValue();
                //      access Parameter class at  Index & update its value.
                parameterArray
=(ArrayList)getParameterModel().getWrappedData();
                ((Parameter)parameterArray.get(index)).setValue(newValue);
                
                //wrap the arrayList back into the ListDataModel
                getParameterModel().setWrappedData(parameterArray);
}


MODEL:
public class Parameter {
        
        private Integer id;
        private Integer variableId;
        private Integer jobId;
        private String  value;

 /** getters and setters ....
}


-----Original Message-----
From: Jason Nichols [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 05, 2005 10:49 PM
To: 'MyFaces Discussion'
Subject: RE: is it possible to edit dynamic Tabular data?

All:
 Thank you for your replies. Of the three ideas I've tried the two most
straightforward and unfortunately I don't think they worked. I'm going to
try Bruno's idea of using a valueChangeListener next.

If anyone's interested the pages are at http://npgrid.fsu.edu 

detail:
1) <x:dataTable preserveDataModel = "true" (also tried ="false")
This didn't work, and if I understand Slawek's description of
preserveDataModel it seems like it does the exact opposite: it prevents the
data model from changing. 

2) ExternalContext 
I haven't tried ExternalContext exactly b/c I in my original debugging I
examined facesContext() durnig the action method called by the form
commandButton, which should give me the request values since I'm logging in
phase 5 and the request values should have updated in phase 2. Please
correct me if I'm wrong on this.
Combinations of facesContext.getViewRoot().getChildren() produced this log:

jobVariables sent to user:  [a, b, c] /** original strings in model **/
[EMAIL PROTECTED], /**<x:dataTable ...**/
[EMAIL PROTECTED]                /** <h:column ...
**/
[EMAIL PROTECTED]/**  <h:inputText  **/
jobVariables received back: [a, b, c] /** should be new values **/

Thanks again and I'll let you know how Bruno's idea works. I've found
several posts in various forums asking how to do this with no answers, so
maybe I could write a custom inputText component.
Regards,
Jason

Reply via email to