使用 Struts2 jQuery 插件填充对话框内的下拉列表

2022-01-16 00:00:00 json java jsp struts2 struts2-jquery

我有一个对话框,我必须从数据库中填充一个下拉列表.我正在使用 struts2-juery-plugins 来实现对话框.此对话框在某些事件上打开.这就是我创建 Dialog 的方式.

I have a Dialog in which I have to populate a dropdown list from database.I am using struts2-juery-plugins to implement Dialog.This Dialog is open on some event. This is how I create Dialog .

<sj:dialog 
     id="mybuttondialog"
     href="%{fillUser}"
     buttons="{
            'Assign':function() { approoveButton(); },
            'Deny':function() { denyButton(); }
            }"
     autoOpen="false"
     modal="true"
     title="Assign-Task"
     closeTopics="closeThisDialog">
<label>User</label>
  <select id="userCombo" name="userCombo">
    <s:iterator value="userList">
      <option><s:property value="helper_name" /></option>
    </s:iterator>
  </select>    
</sj:dialog>

我正在调用一个动作来使用

I am calling an action to fill dropdown list using

<s:url var="fillUser" action="getAllUsers" />

但列表未填充,Dialog 被 jsonData 填充,如下所示

But list is not populating and Dialog got filled with jsonData as following

{"helpDeskUsers":"success","userList":
[{"departments":null,"helper_name":"arvin","helper_value":null,"user_level":null},
{"departments":null,"helper_name":"anand","helper_value":null,"user_level":null},
{"departments":null,"helper_name":"Nehal","helper_value":null,"user_level":null},

为什么列表没有填充,而是整个 Dailog 都填充了上述数据.任何帮助都会很棒.

Why list is not populating instead whole Dailog is filled with above data. Any help would be great.

推荐答案

<select 标签不能用于 json 列表,你应该使用类似

The <select tag will not work with json list, you should use something like

<s:url var="fillUser" action="getAllUsers" />
<sj:select
  id="userjson"
  name="users"
  href="%{fillUser}"
  list="userList"
  listValue="helper_name"
  listKey="helper_name"

相关文章