1

我还是 SmartGWT 的新手,目前有一个奇怪的问题..

我正在使用 Windows XP 和 SmartGWT 3.0 版、GWT SDK 2.4.0(使用 Eclipse IDE)。

所以我的问题是,我从 SmartGWT 展示中复制了一些示例:Styled ComboBox

DynamicForm df = new DynamicForm();
ComboBoxItem cb = new ComboBoxItem();
cb.setValueMap("cat", "dog", "bird");
cb.setTitle("Select:");
df.setItems(cb);
...
layout.addMember(df);

当我将它作为 Web 应用程序运行时,值图不会出现。我的意思是,[v] 按钮在那里,但是当我单击它时没有任何反应..

抱歉这个菜鸟问题,感谢您的帮助!:D


更新 - 2012 年 5 月 3 日

这是我的浏览器上显示的内容:

截图已移除

这是完整的独立代码:

HelloWorld.java

package com.example.helloworld.client;

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.ComboBoxItem;


    public class HelloWorld implements EntryPoint {

        public void onModuleLoad() {

            VLayout layout = new VLayout();
            layout.setWidth100();
            layout.setHeight100();

            DynamicForm df = new DynamicForm();
            ComboBoxItem cb = new ComboBoxItem();
            cb.setTitle("Select :");
            cb.setValueMap("Cat", "Dog", "Bird");

            df.setItems(cb);
            layout.addMember(df);

            layout.draw();
        }
    }

HelloWorld.gwt.xml

<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='helloworld'>
  <!-- Inherit the core Web Toolkit stuff.                        -->
  <inherits name='com.google.gwt.user.User'/>

  <!-- Inherit the default GWT style sheet.  You can change       -->
  <!-- the theme of your GWT application by uncommenting          -->
  <!-- any one of the following lines.                            -->

  <!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
  <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
  <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/>     -->

  <!-- Other module inherits                                      -->
  <inherits name="com.smartgwt.SmartGwt" />

  <!-- Specify the app entry point class.                         -->
  <entry-point class='com.example.helloworld.client.HelloWorld'/>

  <!-- Specify the paths for translatable code                    -->
  <source path='client'/>
  <source path='shared'/>
</module>

在 Eclipse 中的“开发模式”选项卡上(显示链接以在浏览器上运行的选项卡),我收到以下消息:

[INFO] [helloworld] - 您的 *.gwt.xml 模块配置禁止使用当前文档呈现模式 (document.compatMode='CSS1Compat')。
修改您的应用程序的主机 HTML 页面文档类型,或更新您的自定义“document.compatMode”配置属性设置。

还有一个警告:

以下类路径条目“C:\some-path\smartgwt-3.0\smartgwt.jar”在服务器的类路径中不可用。


更新 2 - HTML 和 CSS 文件

HTML:

<!doctype html>
<!-- The DOCTYPE declaration above will set the     -->
<!-- browser's rendering engine into                -->
<!-- "Standards Mode". Replacing this declaration   -->
<!-- with a "Quirks Mode" doctype is not supported. -->

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">

    <!--                                                               -->
    <!-- Consider inlining CSS to reduce the number of requested files -->
    <!--                                                               -->
    <link type="text/css" rel="stylesheet" href="HelloWorld.css">

    <!--                                           -->
    <!-- Any title is fine                         -->
    <!--                                           -->
    <title>Web Application Starter Project</title>

    <!--                                           -->
    <!-- This script loads your compiled module.   -->
    <!-- If you add any GWT meta tags, they must   -->
    <!-- be added before this line.                -->
    <!--                                           -->
    <script type="text/javascript" language="javascript" src="helloworld/helloworld.nocache.js"></script>
  </head>

  <!--                                           -->
  <!-- The body can have arbitrary html, or      -->
  <!-- you can leave the body empty if you want  -->
  <!-- to create a completely dynamic UI.        -->
  <!--                                           -->
  <body>

    <!-- OPTIONAL: include this if you want history support -->
    <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>

    <!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
    <noscript>
      <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
        Your web browser must have JavaScript enabled
        in order for this application to display correctly.
      </div>
    </noscript>

  </body>
</html>

和 CSS 文件:

/** Add css rules here for your application. */


/** Example rules used by the template application (remove for your app) */
h1 {
  font-size: 2em;
  font-weight: bold;
  color: #777777;
  margin: 40px 0px 70px;
  text-align: center;
}

.sendButton {
  display: block;
  font-size: 16pt;
}

/** Most GWT widgets already have a style name defined */
.gwt-DialogBox {
  width: 400px;
}

.dialogVPanel {
  margin: 5px;
}

.serverResponseLabelError {
  color: red;
}

/** Set ids using widget.getElement().setId("idOfElement") */
#closeButton {
  margin: 15px 6px 6px;
}

重要更新

我忘了告诉你,我目前正在使用 Google Chrome(18.0.1025.168) 进行调试/测试构建。当我在 Firefox 上运行它时,它运行正常!

我注意到这个线程有点晚了。所以这是目前已知的错误。

结论:不要将谷歌浏览器用于 GWT / smartGWT 开发模式(目前)。

谢谢您的帮助!:D

4

5 回答 5

1

我忘了告诉你,我目前正在使用 Google Chrome(18.0.1025.168) 进行调试/测试构建。当我在 Firefox 上运行它时,它运行正常!

我注意到这个线程(智能客户端论坛)有点晚了。所以这是一个已知的错误。

结论:不要将谷歌浏览器用于 GWT / smartGWT 开发模式(目前)。

谢谢您的帮助!:D

于 2012-05-04T07:45:40.243 回答
0

ComboBox 不是 SmartGWT。它来自哪里?

此代码按预期工作:

DynamicForm df = new DynamicForm();
ComboBoxItem cb = new ComboBoxItem();
cb.setValueMap("cat", "dog", "bird");
cb.setTitle("Select");
df.setItems(cb);

HLayout layout = new HLayout();
layout.addMember(df);
layout.draw();
于 2012-05-02T15:34:39.680 回答
0

如果您处于调试模式,您将永远看不到此 selectItem 或组合框的内容,但如果您使用键盘向下选择,您将看到内容。您应该处于“生产”模式才能正确查看所有内容

是chrome的问题,如果你使用firefox你会看到内容

于 2012-09-25T16:26:26.000 回答
0
DynamicForm df = new DynamicForm();
ComboBox cb = new ComboBox();
cb.setValueMap("cat", "dog", "bird");
cb.setTitle("Select:");
//other fields
df.setFields(cb); // Use this to add fields
layout.addMember(df);

看看展示柜

于 2012-05-02T03:57:21.257 回答
0

尝试这个..

    DynamicForm df = new DynamicForm();
    ComboBox cb = new ComboBox();
    Map<String,String> valuesMap = new HashMap<String,String>();
    valuesMap.put("cat","cat");
    valuesMap.put("dog","dog");
    valuesMap.put("bird","bird");
    cb.setValueMap(valuesMap);
    cb.setTitle("Select:");
    df.setItems(cb);
    ...
    layout.addMember(df);
于 2012-05-01T17:25:26.997 回答