如何填充下拉(

时间:2012-11-05 19:45:37

标签: select struts2 struts2-jquery

我无法在我的jsp页面中填充我的Struts2选择下拉列表。 注意:我的jsp页面通过json响应加载。 我在表单中有一个选择框。但是当我的jsp页面加载时,我不知道如何填充它。

在同一页面中,我在我的Struts2 jquery网格中有一个选择下拉列表,我能够普及,但我不知道如何为我的表格填充下拉网格的下拉列表。

请帮我解决这个问题。

我的jsp页面

       <s:url id="selecturl" action="selectaction"/>  


   <s:url id="bookediturl" action="bookeditt"/>
   <s:url  id="bookremoteurl" action="booksetups"/>      
        <sjg:grid
        id="bookgrid"
        formIds="form2"
        reloadTopics="reloadMyGrid"
        caption="List of Cover Details"
        dataType="json"
        href="%{bookremoteurl}"
        pager="true"
        gridModel="gridModel"
        rowList="50,100,5000"
        rowNum="20"
        filter="true"
        filterOptions="{stringResult :false,searchOnEnter : false,enableClear : true,gridModel : true}"   
        rownumbers="true"
        editurl="%{bookediturl}"
        navigator="true" 
        editinline="true" 
        navigatorSearch="false"
        autowidth="false"   
        width= "1550" 
        viewrecords="true"  
        navigatorRefresh="true"
        navigatorDelete="true">


             <sjg:gridColumn name="id" index="locationId" title="ID" formatter="integer" sortable="false" key="true" 
                       search="false"  editable="true"  hidden="true"   /> 
              <sjg:gridColumn name="authLastname" index="authLastname" title="AuthorLastname" sortable="true" search="true" editrules="{required: true}"
                        editable="true" edittype="text" />  

        <sjg:gridColumn name="subjectId" title="Subject Name" editable="true" sortable="false" align="center" search="false" searchtype="select" 
        searchoptions="{dataUrl:'%{selecturl}'}"  edittype="select"     editoptions="{dataUrl:'%{selecturl}'}"  />   
        </sjg:grid>

<div id="myDivBox" style="display:none; width :300px;position: relative;top: -30px;left: 299px;button:0px;">
    <s:form action="searchkeywordss" id="form2"  theme="simple" cssClass="yform">
             <sj:textfield  placeholder="Enter keyword to search" cssClass="txtbox" size="42" maxLength="255" name="keywordsearch"/> 
             <sj:select    href="%{selecturl}"   name="countryselect" list="%{lstsub}"  listKey="id" listValue="subjectName"  theme="jquery" cssStyle="margin-top:4px;"/>
             <sj:a button="true" id="btnid"  cssStyle="position: relative;top: 0px;left: 09px;" onClickTopics="reloadMyGrid">Find</sj:a> 
      </s:form> 
</div> 

struts.xml中

 <action name="booksetups" class="v.esoft.actions.bookdetails.BookdetailsAction" >
      <result name="success" type="json"/>
      <result name="login" type="redirect"> /index.jsp </result>
 </action>   
     <action name="selectaction" class="v.esoft.actions.bookdetails.SelectAction">
     <result name="success">/select.jsp</result>
 </action>

1 个答案:

答案 0 :(得分:0)

您应该只使用下面的sj:select

<sj:select    href="%{selecturl}"   name="countryselect" list="subjectList"  listKey="id" listValue="subjectName"  theme="jquery" cssStyle="margin-top:4px;"/>

其中selecturl返回json个回复,subjectList是包含选项的json响应中的列表名称

你的selectaction应该有一个json响应,但你现在拥有的是一个返回jsp的动作,所以它不起作用。如果您无法更改它,则应创建另一个返回json的操作。