Home arrow Java arrow Page 4 - JSP Basics with Java Studio Creator 2 for VB Programmers
JAVA

JSP Basics with Java Studio Creator 2 for VB Programmers


If you have been looking for a place to start with Java Server Pages, you've found it here. This article will give you some hands-on experience in using the Java Studio Creator 2 IDE to create Java Server Pages.

Author Info:
By: Jayaram Krishnaswamy
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
September 25, 2006
TABLE OF CONTENTS:
  1. · JSP Basics with Java Studio Creator 2 for VB Programmers
  2. · The Palette window and more
  3. · Creating a simple JSP page
  4. · Adding basic components to the page
  5. · Test the page

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
JSP Basics with Java Studio Creator 2 for VB Programmers - Adding basic components to the page
(Page 4 of 5 )

Adding a button and a label

Drag and drop a button and a label from the Palette's Basic elements node as shown in the next picture. You can right click to produce a pop-up menu from which you can take several types of actions and changes.

The addition of these controls add the following code between <ui:form binding="# {Page1.form1}" id="form1"/> tags as shown. You can change the properties and placement of control  from here as well.

<ui:form binding="#{Page1.form1}" id="form1">
<ui:label binding="#{Page1.label1}" 
id="label1"
style="height: 24px; left: 36px; top: 36px; 
position: absolute; width: 178px" text="Label"/> <ui:button binding="#{Page1.button1}" id="button1" style="position: absolute; left: 36px; top: 96px;
width: 144px; height: 24px" text="Button"/> </ui:form>

Similarly the tabbed page Java gets changed to reflect these additions by adding two more imports,

import com.sun.rave.web.ui.component.Label; import com.sun.rave.web.ui.component.Button;

with the additional property get, set procedures for the added elements.

Changing the Text property of the elements

By right clicking the elements (controls) and choosing Edit Text from the drop down, the current text of the elements gets highlighted, which may now be typed over. The text "Button" was changed to "Greet" and the text label was changed to "Greet the visitor" as shown. You may verify that these get changed in the tabbed page, JSP. Also you change the "Greet the Visitor" text to "Greet the SUN Visitor" and it gets changed in the design page.  So changes made in Design get changed in JSP and vice versa.

Changing the labels with the button click

When you click the button in the tabbed page Design you open up the tabbed page Java as shown here.

We want to set the label's text property to something other than the current text, "Greet the SUN visitor." Let's change this to "Have a Cup of Java" by using the setValue() method. The picture also shows the code completion feature, which shows up as soon as you type label1 and the period. In some cases the code completion may not immediately show up. This picture shows that the method comes from the com.sun.rave.web.ui.component.Label class. Click on setValue(), which requires an argument.

The completed portion of the code is shown in the next window.  The return null; statement means the page is returned to the same page after the action is completed.


blog comments powered by Disqus
JAVA ARTICLES

- Deploying Multiple Java Applets as One
- Deploying Java Applets
- Understanding Deployment Frameworks
- Database Programming in Java Using JDBC
- Extension Interfaces and SAX
- Entities, Handlers and SAX
- Advanced SAX
- Conversions and Java Print Streams
- Formatters and Java Print Streams
- Java Print Streams
- Wildcards, Arrays, and Generics in Java
- Wildcards and Generic Methods in Java
- Finishing the Project: Java Web Development ...
- Generics and Limitations in Java
- Getting Started with Java Web Development in...

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 6 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials