From jbosstools-commits at lists.jboss.org Thu Mar 4 07:44:42 2010
Content-Type: multipart/mixed; boundary="===============5362327573458175170=="
MIME-Version: 1.0
From: jbosstools-commits at lists.jboss.org
To: jbosstools-commits at lists.jboss.org
Subject: [jbosstools-commits] JBoss Tools SVN: r20648 - in
branches/jbosstools-3.1.x/struts/docs/struts_tools_tutorial: en and 1 other
directory.
Date: Thu, 04 Mar 2010 07:44:42 -0500
Message-ID: <201003041244.o24CigoD012462@svn01.web.mwc.hst.phx2.redhat.com>
--===============5362327573458175170==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: ochikvina
Date: 2010-03-04 07:44:41 -0500 (Thu, 04 Mar 2010)
New Revision: 20648
Modified:
branches/jbosstools-3.1.x/struts/docs/struts_tools_tutorial/en/master.xml
branches/jbosstools-3.1.x/struts/docs/struts_tools_tutorial/en/master_ou=
tput.xml
branches/jbosstools-3.1.x/struts/docs/struts_tools_tutorial/pom.xml
Log:
https://jira.jboss.org/jira/browse/JBDS-1107 -Updated docs source files =
here with the ones for JBDS 3.0.0 GA release.
Modified: branches/jbosstools-3.1.x/struts/docs/struts_tools_tutorial/en/ma=
ster.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/jbosstools-3.1.x/struts/docs/struts_tools_tutorial/en/master.x=
ml 2010-03-04 12:40:59 UTC (rev 20647)
+++ branches/jbosstools-3.1.x/struts/docs/struts_tools_tutorial/en/master.x=
ml 2010-03-04 12:44:41 UTC (rev 20648)
@@ -43,14 +43,14 @@
SvetlanaMukhina<=
email>smukhina(a)exadel.com
=
- 2007
+ 20072008
- 2009
+ 20092010JBoss by Red Hat
- Version: 3.1.0.CR1
+ Version: 3.1.0.GA
=
Modified: branches/jbosstools-3.1.x/struts/docs/struts_tools_tutorial/en/ma=
ster_output.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/jbosstools-3.1.x/struts/docs/struts_tools_tutorial/en/master_o=
utput.xml 2010-03-04 12:40:59 UTC (rev 20647)
+++ branches/jbosstools-3.1.x/struts/docs/struts_tools_tutorial/en/master_o=
utput.xml 2010-03-04 12:44:41 UTC (rev 20648)
@@ -22,1371 +22,1373 @@
=
=
-]>
- =
-
- Struts Tools Tutorial
-
-
-
-
- =
-
-
- =
- =
-
- AnatolyFedosik=
author>
- OlgaChikvina
- SvetlanaMukhina<=
email>smukhina(a)exadel.com
- =
- April 2008
-
- 2007
- 2009
- JBoss by Red Hat
-
-
- Version: 3.1.0.CR1
-
-
-
-
-
- PDF version
-
-
-
-
- =
- =
- =
- =
- =
-
-
-
-
- JBoss Tools
- Eclipse
- Java
- JBoss
-
-
- Introduction
- The following chapters describe how to deal with classic/old style=
of Struts development. We
- recommend users to use JBoss Seam to
- simplify development, but until then you can read about classical Stru=
ts usage here.
-
- We are going to show you how to create a simple
- Struts application
- using the JBoss Tools. The completed application will ask =
a user to enter
- a name and click a button. The resulting new page will display the fam=
iliar message,
- "Hello <name>!"
- This document will show you how to create such an application from=
the beginning, along the
- way demonstrating some of the powerful features of JBoss Tools. With t=
he help of our tutorial you will design the
- application, generate stub code for the application, fill in the stub =
coding, compile the
- application, and finally run it all from inside the Eclipse.
- =
-
- Key Features Struts Tools
- =
- For a start, we propose you to look through the table of main fe=
atures of Struts
- Tools:
-
- =
- Key Functionality of Struts Tools
-
- =
-
-
- =
- =
-
-
- Feature
- Benefit
- =
-
-
-
-
- Struts Support
- Step-by-step wizards for creating a new struts pr=
oject with a number
- of predefined templates, importing existing ones and adding =
struts
- capabilities to non-struts web projects.
- =
-
- =
-
- Support for Struts Configuration File
- Working on file using three modes: diagram, tree =
and source.
- Synchronization between the modes and full control over the =
code. Easy
- moving around the diagram using the Diagram Navigator. Worki=
ng with
- struts projects that have multiple modules. Possibility to u=
se Struts
- configuration file debugger allowing to set break points on =
struts
- diagram and then launch the server in debug mode.
- =
-
- =
-
- Support for Struts modules
- A Struts module (struts-config.xml) is automatica=
lly created while
- creating a new project. There is also possibility to add new=
ones or edit
- already existing modules in your existing project or while i=
mporting Struts project.
- =
-
- =
-
- Verification and Validation
- All occurring errors will be immediately reported=
by verification
- feature, no matter in what view you are working. Constant va=
lidation and
- errors checking allows to catch many of the errors during de=
velopment
- process that significantly reduces development time.<=
/entry>
- =
- =
-
-
-
-
-
- =
- =
- =
-
- Other relevant resources on the topic
- =
- All JBoss Developer Studio/JBoss Tools release documentation you=
can find athttp://docs.jboss.o=
rg/tools in the corresponding release directory.
- The latest documentation builds are available at http://download.jboss.or=
g/jbosstools/nightly-docs.
- =
-
- =
-
-
- =
-
-
-
-
- JBoss Tools
- Struts
- Struts Application
-
-
- =
- Creating a Simple Struts Application
- =
- Firstly, we assume that you have already launched Eclipse with <=
property moreinfo=3D"none">JBoss Tools installed and
- also that the Web Development perspect=
ive is the current perspective. (If not, make it
- active by selecting
- Window > Open Perspective > =
Other > Web
- Development
- from the menu bar.)
- =
-
- Starting Up
- We are first going to create a new project for the applicati=
on.
-
-
- Go to the menu bar and select
- File > New > Struts =
Project
-
-
-
- Next enter "StrutsHello" as the project name
-
-
- Leave everything else as it is, and click
- Next
-
-
-
- If you have server runtime already defined, just pas=
s to next point. Otherwise in the
- Runtime section click the
- New button and target at needed server runtime environment. Click
- Finish.=
-
-
- Click
- Next
-
-
-
- Make sure that
- struts-bean.tld
- ,
- struts-html.tld
- , and
- struts-logic.tld
- are checked in the list of included tag librar=
ies and then hit
- Finish
-
-
-
- A "StrutsHello" node should appear in the Package
- Explorer view.
-
-
- Click the plus sign next to
- StrutsHello
- to reveal the child nodes
-
-
- Click the plus sign next to
- WebContent
- under
- StrutsHello
-
-
- Click the plus sign next to
- WEB-INF
- under
- WebContent
-
-
- Then, double-click on the
- struts-config.xml
- node to display a diagram of the Struts applic=
ation configuration
- file in the editing area
-
-
- At this point, its empty except for the background grid line=
s.
-
- =
-
-
- Creating the Application Components
- Now, we will design the application by creating the individu=
al components as
- placeholders first. (We don't have to complete all of the deta=
ils inside the components
- until afterwards.)
-
- Creating JSP Page Placeholders
- Next, let's create and place two JSP pages. We will not =
write any code
- for the files, but only create them as placeholders so tha=
t we can create links to
- them in the diagram. We will write the code a little bit l=
ater.
-
- Creating the Page Placeholders
-
-
- Bring the Web Pr=
ojects view to the front of the Pack=
age Explorer view
- by selecting the
- Web Projects=
property>
- tab next to that tab.
-
-
- Right-click the
- StrutsHello &g=
t; WEB-ROOT (WebContent)
- folder in the Web Projects view and select
- New > Folde=
r...
-
-
-
- Enter
- pages
- for a folder name and click
- Finish
-
-
-
-
- We will keep our presentation files in this =
folder
-
-
-
- Right-click the
- pages=
emphasis> folder and select
- New > File =
> JSP...
-
-
-
-
- For Name type in
- inputname
- (the JSP extension will be automat=
ically added to the file),
- for Template select
- StrutsForm
- and then click on the
- Finish
- button
-
-
- Right-click the
- pages=
emphasis> folder again and select
- New > File =
> JSP...
-
-
-
- For Name type in
- greeting
- , for Template leave as
- Blank,<=
/emphasis> and then click on the
- Finish
- button
-
-
- Just leave these files as is for now.
-
-
- Placing the Page Placeholders
- Lets now place the two pages just created on the dia=
gram.
-
-
- Click on the
- struts-config.=
xml
- tab in the editing area to bring t=
he diagram to the
- front
-
-
- Click on the
- inputname.jsp<=
/property>
- page in the Web Projects view, drag it onto the diagram, and
- drop it
-
- Click on the
- greeting.jsp
- page in the Web Projects view, drag it onto the diagram, and
- drop it to the right of the
- /pages/inputname.j=
sp
- icon with some extra space
-
- You should now have two JSP pages in the diagram.
-
-
-
- Creating an Action Mappings
- Using a context menu on the diagram, we are next going t=
o create an Action
- mapping.
-
-
- Right-click between the two icons and select
- New > Action
-
-
-
- Enter the following values:
-
-
-
- ("GetNameForm" is the name for a form bean that we will =
create
- later.)
-
-
- Click
- Finish
-
-
-
-
- The
- /greeting
- action should appear in four places, in the di=
agram, under the
-
- action-mappings=
node, under the
- struts-config.xml node in Tree view, in Web Pro=
jects
- view and in the Out=
line view. Also, note the asterisk to the right of the name,
-
- struts-config.xml, in the Outline view s=
howing that the file has been changed, but
- not saved to disk.
-
-
- Creating a Link
- Let's now create a link from the
- inputname.jsp page to the action.
-
-
- On the left-hand side of the diagram in the colu=
mn of icons, click on the Create New Connection
- icon( =
-
-
-
- ).
-
-
-
-
- In the connect-the-components mode you are in no=
w, click on the
- /pages/inputname.j=
sp
- icon in the diagram and then click on =
the
- /greeting
- action
-
-
- A link will be created from the page to the action.
-
-
- Creating a Forward
- Next, we are going to create a forward for the action.=
para>
-
-
- On the left-hand side of the diagram in the colu=
mn of icons, click on =
- the Create New Connection
- icon( =
-
-
-
- ), again.
-
-
- =
-
-
- Click on the
- /greeting
- action icon in the diagram and then cl=
ick on the
- pages/greeting.jsp=
- icon
-
-
- That's it. A link will be drawn from the actions=
new greeting
- forward to the
- greeting.jsp JSP page. Note that the forwards name will be
- set based on the name of the target JSP file name.=
If you don't
- like it, you can easily change it
-
-
- Select the
- Tree
- tab at the bottom of the editor window=
(between Diagram and
- Source)
-
-
- Expand the
- struts-config.xml/=
action-mappings/ /greeting
- node and then select the greeting forw=
ard
-
-
- In the Properties Editor to the right, change th=
e text to
- "sayHello" in the
- Name field
-
-
- Select the
- Diagram
- tab at the bottom of the editor window=
and see how the diagram
- is also updated to reflect the change
-
-
-
-
- Creating a Global Forward
- One last component that we need to create in the diagram=
is a global forward.
-
-
- Somewhere in the top-left corner of diagram, rig=
ht-click and select
- New > Global Fo=
rward
-
-
-
- Enter
- getName
- in the
- Name field
-
-
- Select the
- Change...
- button for Path
-
-
- In the Edit Path window, switch to the
- Pages
- tab
-
-
- Expand the
- StrutsHello > W=
EB-ROOT (WebContent) > pages
- node and then select the inputname.jsp=
page
-
-
- Click
- Ok
- .
-
-
- Leave the rest of the fields blank and click
- OK
-
-
-
- A forward object now appears on the diagram and also in =
the global-forwards folder
- in the Outline view.
-
-
- Tidy up the diagram, by clicking and dragging ar=
ound each icon, so that
- the diagram looks something like this:
-
-
-
- Diagram View
-
-
-
-
-
-
-
-
- Creating a Form Bean
- One last thing that we need to do is to create a form be=
an.
-
-
- Switch to the Tree viewer in the editor for the =
- struts-config.xml file, by
- selecting the
- Tree
- tab at the bottom of the editor window=
-
-
- Right-click
- struts-config.xml =
> form-beans
- and select Create Form Bean
-
-
- Enter
- GetNameForm
- in the name field and
- sample.GetNameForm=
- for type
-
-
- Click
- Finish
-
-
-
- To save your changes to struts-config.xml, selec=
t
- File > Save
- from the menu bar
-
-
- Note the disappearance of the asterisk next to the name,=
- struts-config.xml.<=
/emphasis>
-
-
-
- =
-
-
-
-
- JBoss Tools
- Struts
- Struts Application
-
-
- =
- Generating Stub Coding
- We are done with designing the application through the diagr=
am. Now we need to write
- code for the action component. We also need to write an action=
class for the
- /greeting
- mapping along with a FormBean. To aid in the codin=
g phase, JBoss Developer
- Studio can generate Java class stubs for all of the components=
shown in the diagram.
-
-
- Switch back to the diagram, by selecting the
- Diagram
- tab at the bottom of the editor window
-
-
- Right-click a blank space in the diagram and select =
- Generate Java Code
-
-
-
- Leave everything as is in the dialog box and click <=
emphasis>
- Generate
-
-
-
- You should see a screen that says:
- Generated classes: 2
- Actions: 1
- Form beans: 1
-
-
- Click
- Finish
-
-
-
- The Java files will be generated in a
- JavaSource > sample
- folder that you can see in the Package Explorer view under the
- "StrutsHello" node. One Action stub and one FormBean stub will=
have
- been generated.
-
- =
-
-
-
-
- JBoss Tools
- Struts
- Struts Application
-
-
-
- Coding the Various Files
- We will now code both the Java stub classes just generated, =
the JSP files left in as
- placeholders from previous steps, and a new start JSP page we =
will have to create.
-
- Java Stub Classes
-
-
- To finish the two Java classes, switch to the
- Package Explorer=
property>
- view and expand the
- JavaSource > sa=
mple
- folder
-
-
-
- GetNameForm.java
-
-
- Double-click
- GetNameForm.ja=
va
- for editing
-
-
-
- You are looking at a Java stub class that wa=
s generated by JBoss
- Tools. Now we are going to edit the file
-
-
-
- Add the following attributes at the beginnin=
g of the class:
-
-
-
-
-
-
- Inside the reset method, delete the TO DO an=
d throw lines and
- add:
-
-
-
-
-
-
- Inside the validate method, delete the TO DO=
and throw lines and
- add:
-
-
-
-
-
-
- Right-click and select
- Source > Ge=
nerate Getters and Setters
- from the context menu
-
-
- In the dialog box, check the check box for <=
emphasis>
- name,=
emphasis>
- select First method for Insertion point, and c=
lick on the
- OK
- button
-
-
- The final
- GetNameForm.java file should look like this:
-
-
-
-
- Save the file
-
-
-
-
- GreetingAction.java
-
-
- Open
- GreetingAction.jav=
a for editing
-
-
- Inside the execute method, delete the TO DO =
lines and add the
- following:
-
-
-
-
-
- The final version of
- GreetingAction.java should look like this:
-
-
-
-
- Save the file
-
-
- Close the editors for the two Java files
-
-
- The last thing left to do is to code the JSP files w=
hose editors should still
- be open from having been created as placeholders.
-
-
-
- JSP Pages
-
- inputname.jsp
- In this page, the user will enter any name and click=
the
- submit
- button. Then, the greeting action will be =
called through the form.
-
-
- Click on the
- inputname.jsp<=
/property>
- tab in the Editing area to bring i=
ts editor forward
-
-
- In the Web Projects view, expand
- StrutsHello &g=
t; Configuration > default
- > struts-config.xml > action-map=
pings
- and select
- /greeting
-
-
-
- Drag it and drop it between the quotes for t=
he
- "action"
- attribute to the =
- <html:form>
- element in the Source pane of the editor
-
-
- Then type this text on a new line just below=
this line:
-
-
-
-
- Select the
- Visual
- pane of the editor
-
-
- Then, in the JBoss Tools Palette, expand the=
- Struts Form
- library, select
- text
- , and drag it onto the box
-
- Note:
- By default there are only four group=
s on the JBoss Tools
- Palette. If you wish to make some grou=
p visible click the
- Show/H=
ide
- button on the top of palet=
te and in the prompted
- dialog check the group (or groups) you=
want to be shown.
-
-
-
-
-
- JBoss Tools Palette
-
-
-
-
-
-
-
-
- In the Insert Tag dialog box, type in name f=
or property and select
- Finish
-
-
-
- In the StrutsForm library in the JBoss Tools Palette, select
- submit
- , and drag it to right after the te=
xt box in the Visual pane
- of the editor
-
-
- Right-click the
- submit
- button and select =
- <html:submit>
- Attributes from the context menu
-
-
- In the Attributes dialog box, select the
- value
- field and type in "Say Hello!" for=
its
- value
-
-
- After tidying the page source, the Editor window for=
the file should look
- something like this:
-
- Editor Window
-
-
-
-
-
-
-
-
- greeting.jsp
- Next, we will fill in the result page.
-
-
- Click on the
- greeting.jsp=
property>
- tab in the Editing area to bring i=
ts editor forward
-
-
- Type in the following code:
-
-
-
-
- Greeting
-
-
-