Question

I am a newbie to Struts and I need help with using <s:radio within a displaytag table.

One of the columns in my displaytag table has a radio group of "Yes" and "No". This value (Yes or No) would be pre-selected from the DB but the user can change these values and submit the form. For this I am using the following code:

<display:table name="mmiq" pagesize="-1" requestURI="" uid="mmiq">
...
...
<display:column title="Response">
    <s:radio theme="simple" name="mmiq_%{#attr.mmiq_rowNum - 1}"    
            list="#attr.mmiq.response" value="#attr.mmiq.selectedResponse" />
</display:column>

</display:table>

The backing List for this display table is mmiq<RowData>. Bean RowData has an ArrayList<String> response with two values "Yes" and "No" populated in the constructor. A method getSelectedResponse in RowData bean returns the pre-selected value for that bean from the database.

The table is displayed fine and values are preselected as returned from the DB.

However, when the data is to be submitted back to the action class, I am not sure how to capture the changed values for the radio box. At present, when submitted, I get an error (for each row in the display table): No object in the CompoundRoot has a publicly accessible property named 'mmiq_9' (no setter could be found).

Can anyone help me understand what I am doing wrong here and how to fix this? Any help would be highly appreciated!

Was it helpful?

Solution

Try with

<s:radio theme = "simple" 
          name = "mySelectedValue[%{#attr.mmiq_rowNum - 1}]"
          list = "#attr.mmiq.response" 
         value = "#attr.mmiq.selectedResponse" />

and in Action

private List<String> mySelectedValue;

with its Setter.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top