我还是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应用程序运行时,不会显示valuemap。 我的意思是,[v]按钮在那里,但是当我点击它时没有任何反应..
对不起noob问题,谢谢你的帮助! :d
更新 - 05/03/2012
以下是我的浏览器上显示的内容:
截图已删除
以下是完整的独立代码:
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模块配置禁止 使用当前的doucment渲染模式(document.compatMode =' CSS1Compat')。
修改应用程序的主机HTML页面doctype,或 更新自定义'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上运行它时,运行正常!
我注意到这个thread有点迟了。所以这是一个已知的错误。
结论:不要将谷歌浏览器用于GWT / smartGWT开发模式(暂时)。
感谢您的帮助! :d
答案 0 :(得分:1)
我忘了通知您,我目前正在使用Google Chrome(18.0.1025.168)进行调试/测试构建。当我在Firefox上运行它时,运行正常!
我注意到这个thread (smartclient forum)有点迟了。所以这是一个已知的错误。
结论:不要将谷歌浏览器用于GWT / smartGWT开发模式(暂时)。
感谢您的帮助! :d
答案 1 :(得分: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);
答案 2 :(得分: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);
答案 3 :(得分: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();
答案 4 :(得分:0)
如果您处于调试模式,您将永远不会看到此selectItem或comboBox的内容,但如果您使用键盘选择向下,您将看到内容。您应该处于“生产”模式以正确查看所有内容
Chrome是一个问题,如果你使用firefox,你会看到内容