论坛首页 Java企业应用论坛

Web 显示层技术对比(JSP, ASP,PHP,WebObjects)

浏览 9260 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2004-08-17  
Sorry, English is not good, but can't write Chinese from my office.

What I’m doing is try to compare with different Web Languages, techs … doing the same functionality and display page. I am using WebObjects (Apple) and java. I want to know what’s yours, like jsp,php,ASP…..

THE TASK is one user input his/her name in text field, press Submit button and display the username and something else details you wanted, like timestamp from my example.


In My instance, I create one component including example.html, example.wod and example.java, could have other example.woo and example.api but not related with this task.

example.html
<HTML>
<HEAD>
<META NAME="generator" CONTENT="WebObjects 5">
    <TITLE>Compare Site</TITLE>
</HEAD>
<BODY BGCOLOR=#FFFFFF>
<center>

<WEBOBJECT NAME=MyForm>
User Name:<WEBOBJECT NAME=NameInput></WEBOBJECT>
<WEBOBJECT NAME=SubmitBtn></WEBOBJECT>
<hr>
<WEBOBJECT NAME=DisplayControl>
Welcome User <WEBOBJECT Name=NameOutput></WEBOBJECT>!
</WEBOBJECT NAME=DisplayControl>

</WEBOBJECT NAME=MyForm >
</center>
</BODY>
</HTML>


example.wod
MyForm:WOForm{
  multipleSubmit = YES;
}

NameInput:WOTextField {
value = userName;
}
SubmitBtn:WOSubmitButton {
action = sendName;
value="Submit";
}
DisplayControl:WOConditional{
condition=display;
}
NameOutput:WOString {
value= welcomeName;
}


Example.java
import com.webobjects.foundation.*;
import com.webobjects.appserver.*;
import com.webobjects.eocontrol.*;
import com.webobjects.eoaccess.*;

public class Example extends WOComponent {

    String userName, welcomeName;
    boolean display;
   
    public Main(WOContext context) {
        super(context);
        display=false;
    }

    public WOComponent sendName(){
        display=true;
        welcomeName= userName+" "+new NSTimestamp();
        userName="";
        return this.context().page();
    }
}

The initial page is only user name( textfield ) and submit button. When user input name and press button, the details will comes out and textfield set to nothing.

The first time you look my code maybe confuses, but it’s definitely separate presentation page to java code. The wod file would be like transport pipe between them for passing object value(username and welcomeName) or calling method(sendName).

Please give me your answer?
   发表时间:2004-08-24  
So many people read my topic, but why no reply. Not understand my words or not interested in this topic
0 请登录后投票
   发表时间:2004-09-02  
Here is code from ASP.NET
<%@ Page language="c#" Codebehind="WebForm3.aspx.cs" AutoEventWireup="false" Inherits="TAccWebApplication1.WebForm3" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm3</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
&lt;form id="Form1" method="post" runat="server"&gt;
&lt;P&gt;
&lt;asp:TextBox id="txtUserName" runat="server"&gt;&lt;/asp:TextBox&gt;
&lt;asp:Button id="btnSumbit" runat="server" Text="Submit"&gt;&lt;/asp:Button&gt;&lt;/P&gt;
&lt;P&gt;
&lt;asp:Label id="lblWelcome" runat="server"&gt;&lt;/asp:Label&gt;&lt;/P&gt;
&lt;/form&gt;
</body>
&lt;/HTML&gt;


Code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace TAccWebApplication1
{
/// &lt;summary&gt;
/// Summary description for WebForm3.
/// &lt;/summary&gt;
public class WebForm3 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblWelcome;
protected System.Web.UI.WebControls.TextBox txtUserName;
protected System.Web.UI.WebControls.Button btnSumbit;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// &lt;summary&gt;
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// &lt;/summary&gt;
private void InitializeComponent()
{   
this.btnSumbit.Click += new System.EventHandler(this.btnSumbit_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void btnSumbit_Click(object sender, System.EventArgs e)
{
lblWelcome.Text=txtUserName.Text+" "+DateTime.Now.ToShortTimeString();
}
}
}
0 请登录后投票
   发表时间:2004-09-05  
好像少了Velocity
0 请登录后投票
   发表时间:2004-09-07  
我用的是TAPESTRY!
0 请登录后投票
   发表时间:2004-09-09  
please tell me how to write it in your favorite
language or tools.
We can compare them.

thanks
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics