You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by john lee <sh...@yahoo.com> on 2013/08/03 04:27:25 UTC

s:select detail question for preselected

for following jsp, i can retrieve the data from KeywordcategoryAction for no problem,
    the contents of retrieved list is
          Motor
          Electrical
          Temperature
 
<s:url id="remoteurl" action="KeywordcategoryAction"/>
                                <sj:select
                                        href="%{remoteurl}"
                                        id="language"
                                        onChangeTopics="reloadsecondlist"
                                        name="language"
                                        list="languageObjList"
                                        listKey="myKey"
                                        listValue="myValue"
                                        emptyOption="true"
                                        headerKey="-1"
                                        headerValue="Select Category"
                                        value="why"
                                />

but, the default value(why) as defined from KeywordcategoryAction did not working at all
i change from value="why" to value="%{why}', but still not working,
 
the souce code is at following
 
public class ListValue {
  private String myKey;
  private String myValue;
  /* ....set/get here */
}
 
public class Keywordcategory0Action {
  ....
  private List<String>        languageList;
  private List<ListValue>     languageObjList;
  private Map<String, String> languageMap;
  private List<String>        reloadList;
  private String              language;
 ArrayList<String> main_categorys;
 ....
  /* set/get here */
 
        main_categorys= .../* get return from databsse */
 
        languageList = new ArrayList<String>();
        languageObjList = new ArrayList<ListValue>();
        languageMap = new HashMap<String, String>();

        for (String m: main_categorys) {
            languageList.add(m);
            languageMap.put(m,m);
            languageObjList.add(new ListValue(m, m));
            }
        reloadList = new ArrayList<String>();
 
    why="Temperature";
 
    return success;
    }
 
public String getJSON()  throws Exception  {    return execute();  }
 
please advise,
 
thanks in advance
 
john