从数据库值中选择单选按钮

时间:2014-09-12 11:31:36

标签: jsp struts2 radio-button ognl

我正在尝试从数据库值中选择单选按钮

我正在尝试

value="%{userInfoSettings[0].value}" 

没有选择任何收音机。

在迭代userInfoSettings时,它显示正确的值。

   <s:iterator value="spList" var="r" status="st">
       <s:property value="description"/>
       <s:hidden name="uisList[%{#st.index}].settingParam.id" value="%{id}"/>
       <s:radio  name="uisList[%{#st.index}].value" 
                 list="#{'Yes':'Send email','No':'Dont inform'}"
                 value="%{userInfoSettings[0].value}"/>

         <s:iterator value="userInfoSettings" var="x">
              val <s:property value="value"/>
              id <s:property value="id"/>
         </s:iterator>
      id  <s:property value="id"/>
   </s:iterator>

如何解决这个问题?

编辑:

public class UserCommunication extends ActionSupport implements ModelDriven<UserInfoSetting> {

    UserInfoSetting uis = new UserInfoSetting();
    List<UserInfoSetting> uisList = new ArrayList<UserInfoSetting>();
    public String fetchAll() {
            setUisList(dao.fetchAll(lc.getSessionUserId()));
            for (UserInfoSetting a : getUisList()) {
                System.out.println(a.getId() + " " + a.getSettingParam().getId() + " " + a.getValue());
            }
            return SUCCESS;

    }
   //gettersetter
    @Override
    public UserInfoSetting getModel() {
        return uis;
    }

    }

UserInfoSetting.java

public class UserInfoSetting  implements java.io.Serializable {
     private Long id;
     private Atom atom;
     private SettingParam settingParam;
     private String value;
     private Timestamp adddate;
      //getter setter
      }

SettingParam.java

 public class SettingParam implements java.io.Serializable {
    private Long id;
    private String description;
    private int groupId;
    private Date adddate;
    private Set userInfoSettings = new HashSet(0);
    private Set userProfileSettings = new HashSet(0);
    private Set userPostSettings = new HashSet(0);
    private List<UserInfoSetting> userInfoSettingList = new ArrayList<UserInfoSetting>();
    private List<UserProfileSetting> userProfileSettingList = new ArrayList<UserProfileSetting>();
    private List<UserPostSetting> userPostSettingList = new ArrayList<UserPostSetting>();
    //gettersetter
} 

0 个答案:

没有答案