Developing Web Applications using Java Studio Creator - Creating a Web Application using Sun Java Studio Creator: coding the button
(Page 4 of 5 )
Once you have completed all the steps in both of the previous sections, we are now ready to code for the button to display "Hello World" in the label (or "lblMsg").
Go back to "design" mode and double click on "btnShow." At this point, you will be surprised to see the following code:
package samplejavaapp;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.rave.web.ui.component.Body;
import com.sun.rave.web.ui.component.Form;
import com.sun.rave.web.ui.component.Head;
import com.sun.rave.web.ui.component.Html;
import com.sun.rave.web.ui.component.Link;
import com.sun.rave.web.ui.component.Page;
import javax.faces.FacesException;
import com.sun.rave.web.ui.component.Label;
import com.sun.rave.web.ui.component.Button;
public class Page1 extends AbstractPageBean {
.
.
.
.
public String btnShow_action() {
// TODO: Process the button click action. Return value is
a navigation
// case name where null will return to the same page.
}
}
The entire code is automatically created for you to boost your productivity. The entire life cycle of the page is automatically taken care of with the code it has created. You can even customize the above code, if you want to make any modifications to the IDE generated code. It is also advised to not to modify the areas where it has remarked for you to leave alone.
Now, you modify only the "btnShow_action" method so that it looks something like the following:
public String btnShow_action() {
// case name where null will return to the same page.
this.lblMsg.setText("Hello World!");
return null;
}
Next: Creating a Web Application using Sun Java Studio Creator: executing the application >>
More Java Articles
More By Jagadish Chaterjee