DropDownChoice不显示所选值

时间:2012-11-26 21:26:32

标签: jquery wicket dropdownchoice

我有一个DropDownChoice框,可以在load()上加载一个值列表,但是当我从列表中选择一个值时,所选的值不会显示在框中,即使看起来getModelObject()确实检索到了并返回正确的值(我选择的值)。它只是盒子不显示它。我使用Wicket 6.3.0,使用jetty服务器6.1.26和FireFox 17.0,JQuery Mobile 1.2.0,JQuery 1.8.3进行本地测试。有什么建议或想法吗?

以下是Wicket代码:

MetaProfile profile = null;
...
IModel<List<String>> oxeNodeModel = null;
oxeNodeModel = new LoadableDetachableModel<List<String>>() {
           private static final long serialVersionUID = 1L;
            @Override
            protected List<String> load() {
                    try {
                            List<String> names = getOXENodeList(); 
                            //load the OXE node list

                            if (names == null)
                                   return Collections.emptyList();
                            else {
                                    return names;
                            }

                    }catch (Exception e) {
                                  return Collections.emptyList();
                    }
            }
    };

    oxeNodeBox = new DropDownChoice("oxeNode",
            new PropertyModel<String>(profile, "oxeNodeName"), oxeNodeModel);

    oxeNodeBox.setEnabled(true);
    oxeNodeBox.setOutputMarkupId(true);
    add(oxeNodeBox); 

html模板是:

<tr id="oxeNodeRow" name="oxeNodeRow" style="display:none"> 
    <td align="right" nowrap class="fieldLabel"><label for="oxeNode" wicket:id="oxeNodeLabel" class="requiredLabel">OXE Node</label></td> 
    <td colspan="-1"><select id="oxeNode" name="oxeNode" wicket:id="oxeNode"> 
          <option selected>OXENode</option> </select>
    </td> 
</tr>

我在同一个表单上有一堆DropDownChoice框有同样的问题。但是,表单的第一个DropDownChoice没有问题,即,一旦我从列表中进行选择,它确实显示了所选的值。它的wicket代码和html标记如下。希望眼睛更敏锐的人能够发现可能引发问题的差异:

    profileTypeBox = new DropDownChoice<MetaProfileType>("type",
        new PropertyModel<MetaProfileType>(profile, "type"),
        Arrays.asList(MetaProfileType.values()),
        new IChoiceRenderer<MetaProfileType>() {
            private static final long serialVersionUID = 1L;
            @Override
            public Object getDisplayValue(MetaProfileType object) {
                return object.name();
            }
            @Override
            public String getIdValue(MetaProfileType object, int index) {
                return object.name();
            }
        }
    );
    profileTypeBox.setOutputMarkupId(true);
    add(profileTypeBox);

HTML:

                  <td colspan="-1"> <select id="profileType" name="profileType" wicket:id="type">
              <option>default</option>
            </select> </td>

顺便说一句,我也在这里包含html标题以防万一它可能有问题,因为问题出现后我从旧的css标题(注释掉)转换为标准的jquery mobile包括:

    <html xmlns:wicket="http://wicket.apache.org/">
     <head>

      <!-- meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

     <link rel="stylesheet" type="text/css" href="css/custom.css" media="only screen and (max-width: 480px)"/>
     <link rel="stylesheet" type="text/css" href="css/default.css" media="only screen and (min-width: 1025px)"/>
     <link rel="stylesheet" type="text/css" href="css/portrait.css"
      media="all and (max-device-width: 1024px) and (orientation:portrait)"/>
     <link rel="stylesheet" type="text/css" href="css/landscape.css"
      media="all and (max-device-width: 1024px) and (orientation:landscape)"/>
     <meta name="viewport" content="user-scalable=no, width=device-width"/>
     <link rel="stylesheet" href="css/iphone-style-checkboxes.css" type="text/css"/>
     <script type="text/javascript" src="js/iphone-style-checkboxes.js"></script-->

     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
     <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />  
     <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>  
     <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js">    </script>        

     </head>

1 个答案:

答案 0 :(得分:0)

这似乎是一个HTML问题。

第一步:删除colspan =“ - 1”。这是无效的HTML:http://www.w3.org/wiki/HTML/Elements/td