Author: sabrashevich
Date: 2007-10-02 10:06:06 -0400 (Tue, 02 Oct 2007)
New Revision: 3961
Added:
trunk/documentation/GettingStartedGuide/docs/userguide/en/images/newseamproj22.png
trunk/documentation/GettingStartedGuide/docs/userguide/en/images/newseamproj23.png
Modified:
trunk/documentation/GettingStartedGuide/docs/userguide/en/images/SeamNewProj04.png
trunk/documentation/GettingStartedGuide/docs/userguide/en/images/SeamNewProj044.png
trunk/documentation/GettingStartedGuide/docs/userguide/en/images/SeamNewProj045.png
trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GetStartSeamGen.xml
Log:
updated context
Modified:
trunk/documentation/GettingStartedGuide/docs/userguide/en/images/SeamNewProj04.png
===================================================================
(Binary files differ)
Modified:
trunk/documentation/GettingStartedGuide/docs/userguide/en/images/SeamNewProj044.png
===================================================================
(Binary files differ)
Modified:
trunk/documentation/GettingStartedGuide/docs/userguide/en/images/SeamNewProj045.png
===================================================================
(Binary files differ)
Added: trunk/documentation/GettingStartedGuide/docs/userguide/en/images/newseamproj22.png
===================================================================
(Binary files differ)
Property changes on:
trunk/documentation/GettingStartedGuide/docs/userguide/en/images/newseamproj22.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/documentation/GettingStartedGuide/docs/userguide/en/images/newseamproj23.png
===================================================================
(Binary files differ)
Property changes on:
trunk/documentation/GettingStartedGuide/docs/userguide/en/images/newseamproj23.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GetStartSeamGen.xml
===================================================================
---
trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GetStartSeamGen.xml 2007-10-02
13:55:52 UTC (rev 3960)
+++
trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GetStartSeamGen.xml 2007-10-02
14:06:06 UTC (rev 3961)
@@ -13,7 +13,7 @@
<para>The Red Hat Developer Studio provides sophisticated tools for enterprise
applications. With the Red Hat Developer Studio, you can get started very quickly with a
web prototype, and then scale up your application to include enterprise features (e.g.,
business processes, web services, etc.) using the same developer tools. It is a
"scalable" RAD (Rapid Application Development) tool.</para>
- <para>A core element that makes the Red Hat Developer Studio
"scalable" is the JBoss <property>Seam</property> framework.
<property>Seam</property> is a fully featured application framework on top of
Java EE 5. It is also one of the most popular enterprise Java framework today.
<property>Seam</property> deeply integrates many other standard-based or open
source frameworks (e.g., JSF, EJB3, JMS, Web Services, jBPM, JBoss Rules, Ajax4jsf,
RichFaces, Facelets, Spring, iText, Quartz, TestNG etc.), and provides a single
programming model for developers to "drive" those underlying frameworks
via simple annotated POJOs (Plain Old Java Objects). It makes life easier for developers
to tackle complex enterprise applications with many component frameworks.</para>
+ <para>A core element that makes the Red Hat Developer Studio
"scalable" is the JBoss <property>Seam</property> framework.
<property>Seam</property> is a fully featured application framework on top of
Java EE 5. It is also one of the most popular enterprise Java framework today.
<property>Seam</property> deeply integrates many other standard-based or open
source frameworks (e.g., JSF, EJB3, JMS, Web Services, jBPM, JBoss Rules, Ajax4jsf,
RichFaces, Facelets, Spring, iText, Quartz, TestNG, etc.), and provides a single
programming model for developers to "drive" those underlying frameworks
via simple annotated POJOs (Plain Old Java Objects). It makes life easier for developers
to tackle complex enterprise applications with many component frameworks.</para>
<para>In this chapter, we will cover how to build a simple
<property>Seam</property> web application in minutes with the Red Hat
Developer Studio.</para>
@@ -55,7 +55,7 @@
- <para>Now you need to define a connection profile and choose a database. If you
have no connections yet you should create the one.</para>
+ <para>We will use a default connection provided by RHDS.</para>
<orderedlist>
<listitem><para>Click Next in the dialog "JPA
Facet"</para></listitem>
</orderedlist>
@@ -81,60 +81,15 @@
</mediaobject>
</figure>
- <orderedlist continuation="continues">
- <listitem><para>Click New button to create a new connection
profile.</para></listitem>
- </orderedlist>
-
- <figure>
- <title>Create New Connection Profile</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/SeamNewProj045.png"/>
- </imageobject>
- </mediaobject>
- </figure>
-
- <orderedlist continuation="continues">
- <listitem><para>Give a name to your connection and some description.
Click Next.</para></listitem>
- </orderedlist>
- <figure>
- <title>Give a name to connection profile</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/connectionprofile.png"/>
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>Now you need to specify driver and connection details.</para>
- <orderedlist continuation="continues">
- <listitem><para>Select Generic JDBC driver from the drop down list Click
Next.</para></listitem>
- </orderedlist>
- <figure>
- <title>Select Driver</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/connectionprofile2.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>A summary diallog will be prompted. Click Finish.</para>
-
- <figure>
- <title>Summary window</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/connectionprofile7.png"/>
- </imageobject>
- </mediaobject>
- </figure>
+ <para>We will also use a default Hibernate Dialect -
<emphasis>org.hibernate.dialect.HSQLDialect</emphasis> and deploy as a
<emphasis>war</emphasis> archive.</para>
+
<para>The project setup wizard also asks you to configure how
<property>Seam</property> generates code for the project. The
<property>Seam</property> Home Folder should point to a valid
<property>Seam</property> distribution. By default, it is set to the
<property>Seam</property> distribution bundled in your Red Hat Developer
Studio tool. For the deployment format, choose WAR deployment if you want to use POJOs for
UI event handling and business logic; choose EAR deployment if you want to EJB3 beans for
added features. In most web applications, the WAR deployment option would suffice. You
should also enter Java packages for the entity beans (for database mapping) and session
beans (for action handlers). All generated code will be placed in those packages.
</para>
<figure>
<title>Enter Java packages for generated code</title>
<mediaobject>
<imageobject>
- <imagedata fileref="images/SeamNewProj06.png"/>
+ <imagedata fileref="images/SeamNewProj045.png"/>
</imageobject>
</mediaobject>
</figure>
@@ -194,12 +149,12 @@
<title>New form for the application</title>
<mediaobject>
<imageobject>
- <imagedata fileref="images/xxxx.png"/>
+ <imagedata fileref="images/newseamproj22.png"/>
</imageobject>
</mediaobject>
</figure>
- <para>The wizard generate a web page with a single text input field and an
action button. Notice that the generated page uses layout/template.xhtml as a template.
The template page provides the page header, footer, side menu, and CSS styles (see the
template.xhtml for more details). The Simplepage.xhtml is assembled into the template when
the Simplepage.seam URL is loaded.</para>
+ <para>The wizard generate a web page with a single text input field and an
action button. Notice that the generated page uses
<emphasis>layout/template.xhtml</emphasis> as a template. The template page
provides the page header, footer, side menu, and CSS styles (see the template.xhtml for
more details). The Simplepage.xhtml is assembled into the template when the
Simplepage.seam URL is loaded.</para>
<programlisting role="XML"><![CDATA[
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
@@ -242,9 +197,16 @@
</ui:composition>
]]></programlisting>
+ <figure>
+ <title>Generated form</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/newseamproj23.png"/>
+ </imageobject>
+ </mediaobject>
+ </figure>
+ <para>The <emphasis>#{simpleAction.value}</emphasis> notation on
the web page maps to the "value" property in the backend component named
"simpleAction", and the
<emphasis>#{simpleAction.hello}</emphasis> notation indicates that the
<emphasis><property>hello()</property></emphasis> method is called
when the button is clicked on. Here is the "simpleAction" named backend
<property>Seam</property> component generated by the wizard.</para>
- <para>The #{simpleAction.value} notation on the web page maps to the
"value" property in the backend component named
"simpleAction", and the #{simpleAction.hello} notation indicates that
the hello() method is called when the button is clicked on. Here is the
"simpleAction" named backend <property>Seam</property>
component generated by the wizard.</para>
-
<programlisting role="JAVA"><![CDATA[
@Name("simpleAction")
public class SimpleAction {
@@ -281,14 +243,14 @@
}
]]></programlisting>
- <para>Load the Simplepage.seam in the web browser. Type something in the text
field and click on the "hello" button. A JSF message containing the
input string is created by the SimpleAction.hello() method. The message is displayed on
the page via the h:messages tag.</para>
+ <para>Load the Simplepage.seam in the web browser. Type something in the text
field and click on the "hello" button. A JSF message containing the
input string is created by the
<emphasis><property>SimpleAction.hello()</property></emphasis>
method. The message is displayed on the page via the <emphasis
role="bold"><property><h:messages></property></emphasis>
tag.</para>
</section>
<section>
<title>Input Validation</title>
- <para>Notice that in the generated SimpleAction class, there is a @Length
annotation to validate the input when the input string is bound to #{simpleAction.value}.
To see how this works, enter a text string longer than 10 chars and click on the button.
This is what you should see.</para>
+ <para>Notice that in the generated SimpleAction class, there is a
<emphasis>@Length</emphasis> annotation to validate the input when the input
string is bound to <emphasis>#{simpleAction.value}</emphasis>. To see how this
works, enter a text string longer than 10 chars and click on the button. This is what you
should see.</para>
<figure>
<title>The input validation in action</title>
@@ -299,7 +261,7 @@
</mediaobject>
</figure>
- <para><property>Seam</property> supports many different input
validation annotations. To see an example, you can replace the @Length(max=10) annotation
with the following. It would require the input string to have a first name and last name
separated by a space. If the validation fails, the web page would print the customized
error message.</para>
+ <para><property>Seam</property> supports many different input
validation annotations. To see an example, you can replace the
<emphasis>@Length(max=10)</emphasis> annotation with the following. It would
require the input string to have a first name and last name separated by a space. If the
validation fails, the web page would print the customized error message.</para>
<programlisting role="JAVA"><![CDATA[
@NotNull
@@ -329,8 +291,7 @@
<para>Now, let's add a little more logic to the application. We will
add a new boolean property to the action component. If it is set to true, the action would
capitalize the input string and display it on the web page. The following code in the
SimpleAction class implements the logic.</para>
- <programlisting role="JAVA"><![CDATA[
-@Name("simpleAction")
+ <programlisting
role="JAVA"><![CDATA[@Name("simpleAction")
public class SimpleAction {
private boolean convertToCap;
@@ -351,14 +312,12 @@
<para>Next, on the web page, add the following line to display the value
property on the simpleAction component. Notice that code completion is supported for the
JSF EL expression.</para>
- <programlisting role="XML"><![CDATA[
-<p><b>Hello, #{simpleAction.value}</b></p>
+ <programlisting role="XML"><![CDATA[<p><b>Hello,
#{simpleAction.value}</b></p>
]]></programlisting>
<para>Finally, on the web page, we add a boolean selection box component. It is
bound to the
<emphasis><property>convertToCap</property></emphasis> property on
the backend component.</para>
- <programlisting role="XML"><![CDATA[
-<h:selectBooleanCheckbox title="convertToCap"
+ <programlisting role="XML"><![CDATA[<h:selectBooleanCheckbox
title="convertToCap"
value="#{simpleAction.convertToCap}" />
Capitalize the input?
]]></programlisting>
@@ -379,17 +338,32 @@
<section>
<title>Add Security to the Application</title>
- <para>You have probably noticed that the web page template has a login link at
the top of the page. You can use the <property>Seam</property> security
framework to secure access to any web page or web action. You can implement the login
logic in the XXXX method. In the following example, we just use hardcoded username and
password. But you can easily change it to use database, LDAP or any other
means.</para>
+ <para>You have probably noticed that the web page template has a login link at
the top of the page. You can use the <property>Seam</property> security
framework to secure access to any web page or web action. You can implement the login
logic in the <emphasis>checkLoggedIn</emphasis> method. In the following
example, we just use hardcoded username and password. But you can easily change it to use
database, LDAP or any other means.</para>
<programlisting role="JAVA"><![CDATA[
]]></programlisting>
- <para>Then, on the action method, you can use the XXXX annotation to specify
that it is only invoked by authenticated users.</para>
+ <para>Then, on the action method, you can use the
<emphasis>@AroundInvoke</emphasis> annotation to specify that it is only
invoked by authenticated users.</para>
- <programlisting role="JAVA"><![CDATA[
+ <programlisting role="JAVA"><![CDATA[public class
LoggedInInterceptor
+ {
+ @AroundInvoke
+ public Object checkLoggedIn(InvocationContext invocation) throws Exception
+ {
+ boolean isLoggedIn = Contexts.getSessionContext().get("loggedIn")!=null;
+ if (isLoggedIn) {
+ //the user is already logged in
+ return invocation.proceed();
+ }
+ else {
+ //the user is not logged in, fwd to login page
+ return "login";
+ }
+ }
+}
]]></programlisting>
- <para>Now, re-deploy the application and try the XXXX button. The application
redirects to the XXXX page asking for login credentials. The method is invoked after you
successfully logged in.</para>
+ <para>Now, re-deploy the application and try the action button. The application
redirects to the <emphasis>login</emphasis> page asking for login credentials.
The method is invoked after you successfully logged in.</para>
<figure>
<title>Access control for action methods</title>
@@ -400,12 +374,34 @@
</mediaobject>
</figure>
- <para>We can also secure web pages. You can edit the XXXX file to put an access
constraint on the XXXXX page.</para>
+ <para>We can also secure web pages. You can edit the
<emphasis>Authenticator.java</emphasis> file to put an access constraint on
the login page.</para>
- <programlisting role="XML"><![CDATA[
+ <programlisting
role="JAVA"><![CDATA[package.org.domain.MySeamProj.session;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.security.identity;
+
+ @Name ("authenticator")
+ public class Authenticator
+ {
+ @Logger Log log;
+ @In Identity identity;
+
+ public boolean authenticate()
+ {
+ log.info("authenticating #0", identity.getUserName());
+ //write your authentication logic here,
+ //return true if the authentication was
+ //successful, false otherwise
+ identity.addRole("admin");
+ return true;
+ }
+ }
]]></programlisting>
- <para>You can try to load the XXXX URL in the browser and it will redirect to
ask for login.</para>
+ <para>You can try to load the
http://localhost:8080/MySeamProj/ URL in the
browser and it will redirect to ask for login.</para>
</section>