Hi Jason, I have a solution for you using myfaces. There will be more
elegant solutions, but this one should work for you:

I take for granted that you have your variable-length array in a
backing bean (call 'arrayValues' for instance), with public accessor
methods. The code for the jsp page could look like The jsp code could
look like

[CODE]

<h:form>
<x:dataTable var="val" value="#{yourBackingBean.arrayValues}"
rowIndexVar="indexVar">
  <h:column>
        <h:inputText value="#{val}"
valueChangeListener="#{yourBackingBean.updateValue}">
                <f:param name="index" value="#{indexVar}"/>
        </h:inputText>
        </h:column>
  </x:dataTable>

<h:commandButton value="Process array"
action="#{yourBackingBean.processArray}"/>

</h:form>

[/CODE]

Every inputText has its valueChangeListener and a parameter. The
valueChangeListener should point to a method in your bean that
retrieves the new value and the index of the changed component, in
order to update the corresponding values of the array, something like
this:

[CODE]

public void updateValue(ValueChangeEvent vce) {
        // get the new value of the inputText
        String newValue = (String) vce.getNewValue();
        
        // get the child parameter of the inputText (I know it is the
only child), to get the index value
        UIParameter param = (UIParameter)
vce.getComponent().getChildren().get(0);
        Integer index = (Integer) param.getValue();
       
        // update the value in the array 
        arrayValues[index.intValue()] = newValue;
    }

[/CODE]

Then you will have, a column of inputText and one h:commandButton (in
the example calls to a method in your backing bean called
processArray):

Hope this helps,

Regards,

Bruno

2005/7/5, Jason Nichols <[EMAIL PROTECTED]>:
>  
>  
> 
> Another way of asking is can you put h:outputText inside h:dataTable without
> a commandButton/Link on each line. 
> 
>   
> 
> Btw although I'm fairly new to jsf I'm not looking for someone to do my work
> for me, I've been struggling for a week when I realized I've never seen
> anything like this on ANY web page, so if it's 
> 
> just not possible I'd like to learn why. 
> 
> Regards, 
> 
> Jason

Reply via email to