用类似swing的api开发web ui。没有html,没有xml,没有taglib

bbscbb 2003-11-07 04:36:20
用类似swing的api开发web ui。没有html,没有xml,没有taglib,都是java,这个锤子太好了,满世界都是钉子,如果不是,就造个钉子。
感觉啊,象intraweb,嘿嘿,做小东西很方便。

http://wings.mercatis.de/tiki-index.php
主页

http://prdownloads.sourceforge.net/j-wings
下载

http://wingsdemo.mercatis.de/hellowings/WingSTutorial/IC2?4_3=2_1
是tutorial


重点看看:
http://wingsdemo.mercatis.de/hellowings/HelloWingSExt/IC1
是效果,可以修改内容,呵呵,象桌面的程序一样,没有用applet或是activeform,只有css。
以下是servlet的代码
********************************************************************
********************************************************************
********************************************************************
********************************************************************

import org.wings.session.Session;
import org.wings.SContainer;
import org.wings.SLabel;
import org.wings.SButton;
import org.wings.STable;
import org.wings.SFrame;

import javax.servlet.ServletConfig;

/**
* <h1>HelloWingSExtSession.java</h1>
* <p>A very simple <code>SessionServlet</code>.
* </p><p>Only prints out "<code>Hello WingS!</code>" and a little more .</p>
* <p><b>Created 2002, mercatis GmbH</b></p>
**/
public class HelloWingSExt {

/**
* <p>creates the GUI of the webapplication</p>
* @param sess the WingS-Session
**/
public HelloWingSExt ( ) {
SFrame frame = new SFrame();
System.out.println ( "creating new HelloWingSSession" );

// call super-constructor
// get the pane to put components in
SContainer pane = frame.getContentPane();

// create and add a label to the pane
SLabel label = new SLabel ( "Hello WingS!" );
pane.add( label );

// create and add a table to the pane
final javax.swing.table.DefaultTableModel tm =
new javax.swing.table.DefaultTableModel( 10, 10 );
for ( int i = 0; i<10; i++ )
for ( int j = 0; j<10; j++ )
tm.setValueAt ( (i*j)+"", i, j );
STable table = new STable ( tm );
pane.add ( table );

// create and add a button which is changing table entries randomly
SButton button = new SButton ( "Change" );
button.addActionListener ( new java.awt.event.ActionListener () {
public void actionPerformed ( java.awt.event.ActionEvent ae ) {
int row = (int)Math.round(Math.random () * 10000.0) % 10;
int col = (int)Math.round(Math.random () * 10000.0) % 10;
int val = (int)Math.round(Math.random () * 10000.0);
tm.setValueAt ( val+"", row, col );
}
});
pane.add ( button );
frame.show();
}

}// HelloWingSExt

********************************************************************

以下是web.xml
********************************************************************

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>


<!-- loading the HelloWingSExt servlet -->
<servlet>
<servlet-name>HelloWingSExt</servlet-name>
<servlet-class>org.wings.session.WingServlet</servlet-class>
<init-param>
<param-name>wings.mainclass</param-name>
<param-value>HelloWingSExt</param-value>
</init-param>
<init-param>
<param-name>wings.lookandfeel.deploy</param-name>
<param-value>/css1.jar</param-value>
</init-param>
<init-param>
<param-name>wings.lookandfeel.name</param-name>
<param-value>xhtml/css1</param-value>
</init-param>
</servlet>

<!-- the servlet container shall map the HelloWingS -->

<servlet-mapping>
<servlet-name>HelloWingSExt</servlet-name>
<url-pattern>/HelloWingSExt/*</url-pattern>
</servlet-mapping>

<!-- The Welcome File List -->
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

</web-app>
...全文
104 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dekn 2003-11-07
  • 打赏
  • 举报
回复
up

23,407

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧