2012-11-26 36 views
0

我有一个DropDownChoice框可以在load()上加载一个值列表,但是当我从列表中选择一个值时,所选值不会显示在框中,即使它似乎getModelObject()会检索并返回正确的值(我选择的值)。这只是盒子不显示它。我使用Wicket 6.3.0,本地测试使用码头服务器6.1.26和FireFox 17.0,JQuery Mobile 1.2.0,JQuery 1.8.3。任何建议或想法?DropDownChoice不显示选定的值

这里是检票代码:

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没有问题,即,一旦我从列表中进行选择,它就会显示选定的值。它的检票代码和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> 
+0

当你说“从列表中选择一个值”,你的意思是选择通过浏览器使用你的应用程序时的值?或者你的意思是从代码中的列表中选择一个值? – Sarhanis

+0

很抱歉,如果不清楚,我的意思是当用户从浏览器网页上的DropDownChoice列表中手动选择一个值时,所选值不会显示在gui的框中。不,我并不是指以编程方式选择一个值。 –

+0

这听起来不可能。你能展示HTML显示吗?是否有一些AJAX调用?为什么是colspan = -1?这没有意义。 – Sarhanis

回答

0

这似乎是一个HTML的问题。

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

+0

感谢您的输入。我确实尝试删除colspan =“ - 1”,不幸的是,问题依然存在。 –