Web develop language compare
What I’m doing is try to compare with different Web Languages, techs … to do the same functionality and display page. I am using WebObjects (Apple) and java. I want to know what’s yours, like jsp,phpASP…..
THE TASK is one user input his/her name in text field, press Submit button and display the username and some 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 come out and textfield set to nothing.
The first time you look my code maybe confuses, but it’s definitely separate presentation page and java code. The wod file would be like transport pipe for passing object value(username and welcomeName) or calling method(sendName) in the between of html and java code.
|