Seam SVN: r9294 - trunk/seam-gen/icefaces/view.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-10-14 03:33:42 -0400 (Tue, 14 Oct 2008)
New Revision: 9294
Modified:
trunk/seam-gen/icefaces/view/edit.xhtml.ftl
trunk/seam-gen/icefaces/view/list.xhtml
trunk/seam-gen/icefaces/view/view.xhtml.ftl
Log:
fix title in table header on detail page
add iceCmdBtn style to s:button
Modified: trunk/seam-gen/icefaces/view/edit.xhtml.ftl
===================================================================
--- trunk/seam-gen/icefaces/view/edit.xhtml.ftl 2008-10-14 06:22:16 UTC (rev 9293)
+++ trunk/seam-gen/icefaces/view/edit.xhtml.ftl 2008-10-14 07:33:42 UTC (rev 9294)
@@ -56,13 +56,13 @@
immediate="true"
rendered="${'#'}{${homeName}.managed}"/>
- <s:button id="done${homeName}"
+ <s:button id="done${homeName}" styleClass="iceCmdBtn"
value="Done"
propagation="end"
view="/${pageName}.xhtml"
rendered="${'#'}{${homeName}.managed}"/>
- <s:button id="cancel${homeName}"
+ <s:button id="cancel${homeName}" styleClass="iceCmdBtn"
value="Cancel"
propagation="end"
view="/${'#'}{empty ${componentName}From ? '${masterPageName}' : ${componentName}From}.xhtml"
Modified: trunk/seam-gen/icefaces/view/list.xhtml
===================================================================
--- trunk/seam-gen/icefaces/view/list.xhtml 2008-10-14 06:22:16 UTC (rev 9293)
+++ trunk/seam-gen/icefaces/view/list.xhtml 2008-10-14 07:33:42 UTC (rev 9294)
@@ -46,7 +46,7 @@
</div>
</ice:panelGroup>
<div class="actionButtons">
- <s:button id="listDoneId" value="Create @componentName@"
+ <s:button id="listCreateId" value="Create @componentName@" styleClass="iceCmdBtn"
view="/@pageName@.xhtml"/>
</div>
</ice:form>
Modified: trunk/seam-gen/icefaces/view/view.xhtml.ftl
===================================================================
--- trunk/seam-gen/icefaces/view/view.xhtml.ftl 2008-10-14 06:22:16 UTC (rev 9293)
+++ trunk/seam-gen/icefaces/view/view.xhtml.ftl 2008-10-14 07:33:42 UTC (rev 9294)
@@ -22,7 +22,7 @@
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="iceDatTblColHdr2">
- <ice:outputText id="viewText${homeName}Id" value="${homeName}"/>
+ <ice:outputText id="viewText${homeName}Id" value="${entityName}"/>
</td>
</tr>
</table>
@@ -39,11 +39,11 @@
<div id="view${editPageName}searchButtons" class="actionButtons">
<s:button view="/${editPageName}.xhtml"
- id="viewEdit${editPageName}"
+ id="viewEdit${editPageName}" styleClass="iceCmdBtn"
value="Edit"/>
<s:button view="/${'#'}{empty ${componentName}From ? '${masterPageName}' : ${componentName}From}.xhtml"
- id="viewDone${editPageName}"
+ id="viewDone${editPageName}" styleClass="iceCmdBtn"
value="Done"/>
</div>
16 years, 2 months
Seam SVN: r9293 - in trunk/seam-gen: view/layout and 1 other directory.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-10-14 02:22:16 -0400 (Tue, 14 Oct 2008)
New Revision: 9293
Modified:
trunk/seam-gen/icefaces/view/layout/template.xhtml
trunk/seam-gen/view/layout/template.xhtml
Log:
make path to favicon absolute
Modified: trunk/seam-gen/icefaces/view/layout/template.xhtml
===================================================================
--- trunk/seam-gen/icefaces/view/layout/template.xhtml 2008-10-14 06:12:29 UTC (rev 9292)
+++ trunk/seam-gen/icefaces/view/layout/template.xhtml 2008-10-14 06:22:16 UTC (rev 9293)
@@ -12,7 +12,7 @@
doctypeSystem="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>@projectName@</title>
- <link rel="shortcut icon" href="favicon.ico"/>
+ <link rel="shortcut icon" href="#{requestPath}/favicon.ico"/>
<link rel='stylesheet' type='text/css' href='./xmlhttp/css/rime/rime.css'/>
<link href="stylesheet/theme.css" rel="stylesheet" type="text/css" />
<ui:insert name="head"/>
Modified: trunk/seam-gen/view/layout/template.xhtml
===================================================================
--- trunk/seam-gen/view/layout/template.xhtml 2008-10-14 06:12:29 UTC (rev 9292)
+++ trunk/seam-gen/view/layout/template.xhtml 2008-10-14 06:22:16 UTC (rev 9293)
@@ -11,7 +11,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>@projectName@</title>
- <link rel="shortcut icon" href="favicon.ico"/>
+ <link rel="shortcut icon" href="#{requestPath}/favicon.ico"/>
<a:loadStyle src="resource:///stylesheet/theme.xcss"/>
<a:loadStyle src="/stylesheet/theme.css"/>
<ui:insert name="head"/>
16 years, 2 months
Seam SVN: r9292 - trunk/seam-gen/src.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-10-14 02:12:29 -0400 (Tue, 14 Oct 2008)
New Revision: 9292
Modified:
trunk/seam-gen/src/Action.java
trunk/seam-gen/src/ActionBean.java
trunk/seam-gen/src/ActionJavaBean.java
trunk/seam-gen/src/Authenticator.java
trunk/seam-gen/src/Conversation.java
trunk/seam-gen/src/ConversationBean.java
trunk/seam-gen/src/ConversationJavaBean.java
trunk/seam-gen/src/Entity.java
trunk/seam-gen/src/EntityHome.java
trunk/seam-gen/src/FormAction.java
trunk/seam-gen/src/FormActionBean.java
trunk/seam-gen/src/FormActionJavaBean.java
trunk/seam-gen/src/Query.java
Log:
fix sloppy formatting
Modified: trunk/seam-gen/src/Action.java
===================================================================
--- trunk/seam-gen/src/Action.java 2008-10-14 05:53:26 UTC (rev 9291)
+++ trunk/seam-gen/src/Action.java 2008-10-14 06:12:29 UTC (rev 9292)
@@ -5,8 +5,9 @@
@Local
public interface @interfaceName@ {
- //seam-gen method
- public void @methodName@();
+ // seam-gen method
+ public void @methodName@();
- //add additional interface methods here
-}
\ No newline at end of file
+ // add additional interface methods here
+
+}
Modified: trunk/seam-gen/src/ActionBean.java
===================================================================
--- trunk/seam-gen/src/ActionBean.java 2008-10-14 05:53:26 UTC (rev 9291)
+++ trunk/seam-gen/src/ActionBean.java 2008-10-14 06:12:29 UTC (rev 9292)
@@ -17,11 +17,11 @@
public void @methodName@()
{
- //implement your business logic here
+ // implement your business logic here
log.info("@componentName@.@methodName@() action called");
facesMessages.add("@methodName@");
}
- //add additional action methods
+ // add additional action methods
}
Modified: trunk/seam-gen/src/ActionJavaBean.java
===================================================================
--- trunk/seam-gen/src/ActionJavaBean.java 2008-10-14 05:53:26 UTC (rev 9291)
+++ trunk/seam-gen/src/ActionJavaBean.java 2008-10-14 06:12:29 UTC (rev 9292)
@@ -15,11 +15,11 @@
public void @methodName@()
{
- //implement your business logic here
+ // implement your business logic here
log.info("@componentName@.@methodName@() action called");
facesMessages.add("@methodName@");
}
- //add additional action methods
+ // add additional action methods
}
Modified: trunk/seam-gen/src/Authenticator.java
===================================================================
--- trunk/seam-gen/src/Authenticator.java 2008-10-14 05:53:26 UTC (rev 9291)
+++ trunk/seam-gen/src/Authenticator.java 2008-10-14 06:12:29 UTC (rev 9292)
@@ -7,7 +7,6 @@
import org.jboss.seam.security.Credentials;
import org.jboss.seam.security.Identity;
-
@Name("authenticator")
public class Authenticator
{
@@ -29,4 +28,5 @@
}
return false;
}
+
}
Modified: trunk/seam-gen/src/Conversation.java
===================================================================
--- trunk/seam-gen/src/Conversation.java 2008-10-14 05:53:26 UTC (rev 9291)
+++ trunk/seam-gen/src/Conversation.java 2008-10-14 06:12:29 UTC (rev 9292)
@@ -5,12 +5,13 @@
@Local
public interface @interfaceName@ {
- //seam-gen methods
- public String begin();
- public String increment();
- public String end();
- public int getValue();
- public void destroy();
+ // seam-gen methods
+ public String begin();
+ public String increment();
+ public String end();
+ public int getValue();
+ public void destroy();
+
+ // add additional interface methods here
- //add additional interface methods here
-}
\ No newline at end of file
+}
Modified: trunk/seam-gen/src/ConversationBean.java
===================================================================
--- trunk/seam-gen/src/ConversationBean.java 2008-10-14 05:53:26 UTC (rev 9291)
+++ trunk/seam-gen/src/ConversationBean.java 2008-10-14 06:12:29 UTC (rev 9292)
@@ -13,40 +13,41 @@
@Name("@componentName@")
public class @beanName@ implements @interfaceName@ {
- @Logger private Log log;
+ @Logger private Log log;
- private int value;
+ private int value;
- @Begin
- public String begin()
- {
- //implement your begin conversation business logic
- log.info("beginning conversation");
- return "success";
- }
-
- public String increment()
- {
- log.info("incrementing");
- value++;
- return "success";
- }
-
- //add additional action methods that participate in this conversation
-
- @End
- public String end()
- {
- //implement your end conversation business logic
+ @Begin
+ public String begin()
+ {
+ // implement your begin conversation business logic
+ log.info("beginning conversation");
+ return "success";
+ }
+
+ public String increment()
+ {
+ log.info("incrementing");
+ value++;
+ return "success";
+ }
+
+ // add additional action methods that participate in this conversation
+
+ @End
+ public String end()
+ {
+ // implement your end conversation business logic
log.info("ending conversation");
- return "home";
- }
+ return "home";
+ }
+
+ public int getValue()
+ {
+ return value;
+ }
+
+ @Destroy @Remove
+ public void destroy() {}
- public int getValue()
- {
- return value;
- }
-
- @Destroy @Remove
- public void destroy() {}
}
Modified: trunk/seam-gen/src/ConversationJavaBean.java
===================================================================
--- trunk/seam-gen/src/ConversationJavaBean.java 2008-10-14 05:53:26 UTC (rev 9291)
+++ trunk/seam-gen/src/ConversationJavaBean.java 2008-10-14 06:12:29 UTC (rev 9292)
@@ -13,38 +13,38 @@
@Name("@componentName@")
public class @interfaceName@ {
- @Logger private Log log;
+ @Logger private Log log;
- private int value;
+ private int value;
- @Begin
- public String begin()
- {
- //implement your begin conversation business logic
- log.info("beginning conversation");
- return "success";
- }
-
- public String increment()
- {
- log.info("incrementing");
- value++;
- return "success";
- }
-
- //add additional action methods that participate in this conversation
-
- @End
- public String end()
- {
- //implement your end conversation business logic
+ @Begin
+ public String begin()
+ {
+ // implement your begin conversation business logic
+ log.info("beginning conversation");
+ return "success";
+ }
+
+ public String increment()
+ {
+ log.info("incrementing");
+ value++;
+ return "success";
+ }
+
+ // add additional action methods that participate in this conversation
+
+ @End
+ public String end()
+ {
+ // implement your end conversation business logic
log.info("ending conversation");
- return "home";
- }
+ return "home";
+ }
+
+ public int getValue()
+ {
+ return value;
+ }
- public int getValue()
- {
- return value;
- }
-
}
Modified: trunk/seam-gen/src/Entity.java
===================================================================
--- trunk/seam-gen/src/Entity.java 2008-10-14 05:53:26 UTC (rev 9291)
+++ trunk/seam-gen/src/Entity.java 2008-10-14 06:12:29 UTC (rev 9292)
@@ -10,39 +10,39 @@
@Entity
public class @entityName@ implements Serializable {
- //seam-gen attributes (you should probably edit these)
- private Long id;
- private Integer version;
- private String name;
+ // seam-gen attributes (you should probably edit these)
+ private Long id;
+ private Integer version;
+ private String name;
- //add additional entity attributes
+ // add additional entity attributes
- //seam-gen attribute getters/setters with annotations (you probably should edit)
+ // seam-gen attribute getters/setters with annotations (you probably should edit)
- @Id @GeneratedValue
- public Long getId() {
- return id;
- }
+ @Id @GeneratedValue
+ public Long getId() {
+ return id;
+ }
- public void setId(Long id) {
- this.id = id;
- }
+ public void setId(Long id) {
+ this.id = id;
+ }
- @Version
- public Integer getVersion() {
- return version;
- }
+ @Version
+ public Integer getVersion() {
+ return version;
+ }
- private void setVersion(Integer version) {
- this.version = version;
- }
+ private void setVersion(Integer version) {
+ this.version = version;
+ }
- @Length(max=20)
- public String getName() {
- return name;
- }
+ @Length(max = 20)
+ public String getName() {
+ return name;
+ }
- public void setName(String name) {
- this.name = name;
- }
+ public void setName(String name) {
+ this.name = name;
+ }
}
Modified: trunk/seam-gen/src/EntityHome.java
===================================================================
--- trunk/seam-gen/src/EntityHome.java 2008-10-14 05:53:26 UTC (rev 9291)
+++ trunk/seam-gen/src/EntityHome.java 2008-10-14 06:12:29 UTC (rev 9292)
@@ -10,14 +10,13 @@
@Name("@homeName@")
public class @entityName@Home extends EntityHome<@entityName@>
{
-
@RequestParameter
Long @componentName@Id;
@Override
public Object getId()
{
- if (@componentName@Id==null)
+ if (@componentName@Id == null)
{
return super.getId();
}
Modified: trunk/seam-gen/src/FormAction.java
===================================================================
--- trunk/seam-gen/src/FormAction.java 2008-10-14 05:53:26 UTC (rev 9291)
+++ trunk/seam-gen/src/FormAction.java 2008-10-14 06:12:29 UTC (rev 9292)
@@ -5,10 +5,10 @@
@Local
public interface @interfaceName@ {
- public void @methodName@();
- public String getValue();
- public void setValue(String value);
- public void destroy();
+ public void @methodName@();
+ public String getValue();
+ public void setValue(String value);
+ public void destroy();
- //add additional interface methods here
-}
\ No newline at end of file
+ // add additional interface methods here
+}
Modified: trunk/seam-gen/src/FormActionBean.java
===================================================================
--- trunk/seam-gen/src/FormActionBean.java 2008-10-14 05:53:26 UTC (rev 9291)
+++ trunk/seam-gen/src/FormActionBean.java 2008-10-14 06:12:29 UTC (rev 9292)
@@ -21,15 +21,15 @@
private String value;
public void @methodName@()
- {
- //implement your business logic here
+ {
+ // implement your business logic here
log.info("@componentName@.@methodName@() action called with: #{@componentName@.value}");
facesMessages.add("@methodName@ #{@componentName@.value}");
- }
+ }
- //add additional action methods
+ // add additional action methods
- @Length(max=10)
+ @Length(max = 10)
public String getValue()
{
return value;
Modified: trunk/seam-gen/src/FormActionJavaBean.java
===================================================================
--- trunk/seam-gen/src/FormActionJavaBean.java 2008-10-14 05:53:26 UTC (rev 9291)
+++ trunk/seam-gen/src/FormActionJavaBean.java 2008-10-14 06:12:29 UTC (rev 9292)
@@ -16,24 +16,24 @@
private String value;
- public void @methodName@()
- {
- //implement your business logic here
- log.info("@componentName@.@methodName@() action called with: #{@componentName@.value}");
- facesMessages.add("@methodName@ #{@componentName@.value}");
- }
+ public void @methodName@()
+ {
+ // implement your business logic here
+ log.info("@componentName@.@methodName@() action called with: #{@componentName@.value}");
+ facesMessages.add("@methodName@ #{@componentName@.value}");
+ }
- //add additional action methods
-
- @Length(max=10)
- public String getValue()
- {
- return value;
- }
-
- public void setValue(String value)
- {
- this.value = value;
- }
-
+ // add additional action methods
+
+ @Length(max = 10)
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
}
Modified: trunk/seam-gen/src/Query.java
===================================================================
--- trunk/seam-gen/src/Query.java 2008-10-14 05:53:26 UTC (rev 9291)
+++ trunk/seam-gen/src/Query.java 2008-10-14 06:12:29 UTC (rev 9292)
@@ -23,5 +23,5 @@
public Integer getMaxResults() {
return 25;
}
+
}
-
16 years, 2 months
Seam SVN: r9291 - trunk/src/main/org/jboss/seam/web.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2008-10-14 01:53:26 -0400 (Tue, 14 Oct 2008)
New Revision: 9291
Modified:
trunk/src/main/org/jboss/seam/web/RewritingResponse.java
Log:
woops - one log message still at the wrong level
Modified: trunk/src/main/org/jboss/seam/web/RewritingResponse.java
===================================================================
--- trunk/src/main/org/jboss/seam/web/RewritingResponse.java 2008-10-14 02:06:01 UTC (rev 9290)
+++ trunk/src/main/org/jboss/seam/web/RewritingResponse.java 2008-10-14 05:53:26 UTC (rev 9291)
@@ -42,13 +42,13 @@
@Override
public String encodeURL(String url) {
String result = encode(url);
- log.info("encodeURL " + url + " -> " + result);
+ log.debug("encodeURL " + url + " -> " + result);
return result;
}
@Override
public String encodeRedirectURL(String url) {
- log.info("encode redirectURL called with " + url);
+ log.debug("encode redirectURL called with " + url);
return encodeURL(url);
}
16 years, 2 months
Seam SVN: r9290 - in trunk/doc/Seam_Reference_Guide/en-US: images and 1 other directory.
by seam-commits@lists.jboss.org
Author: jacob.orshalick
Date: 2008-10-13 22:06:01 -0400 (Mon, 13 Oct 2008)
New Revision: 9290
Added:
trunk/doc/Seam_Reference_Guide/en-US/images/nested-booking.png
Modified:
trunk/doc/Seam_Reference_Guide/en-US/Tutorial.xml
Log:
JBSEAM-2295
Modified: trunk/doc/Seam_Reference_Guide/en-US/Tutorial.xml
===================================================================
--- trunk/doc/Seam_Reference_Guide/en-US/Tutorial.xml 2008-10-14 02:02:05 UTC (rev 9289)
+++ trunk/doc/Seam_Reference_Guide/en-US/Tutorial.xml 2008-10-14 02:06:01 UTC (rev 9290)
@@ -2505,7 +2505,7 @@
<section>
<title>The Seam Debug Page</title>
- <para> The WAR also includes <literal>seam-debug.jar</literal>. The Seam debug page will be availabled
+ <para> The WAR also includes <literal>seam-debug.jar</literal>. The Seam debug page will be available
if this jar is deployed in
<literal>WEB-INF/lib</literal>, along with the Facelets, and if you set the debug property
of the <literal>init</literal> component:</para>
@@ -2530,7 +2530,391 @@
</section>
</section>
-
+
+ <section id="nestedbooking">
+ <title>Nested conversations: extending the Hotel Booking example</title>
+
+ <section>
+ <title>Introduction</title>
+
+ <para>Long-running conversations make it simple to maintain consistency of state in an application
+even in the face of multi-window operation and back-buttoning. Unfortunately, simply beginning and ending a
+long-running conversation is not always enough. Depending on the requirements of the application, inconsistencies
+between what the user's expectations and the reality of the application’s state can still result.</para>
+
+ <para>The nested booking application extends the features of the hotel booking application to incorporate
+the selection of rooms. Each hotel has available rooms with descriptions for a user to select from. This requires
+the addition of a room selection page in the hotel reservation flow.</para>
+
+ <mediaobject>
+ <imageobject role="fo">
+ <imagedata fileref="images/nested-booking.png" align="center" scalefit="1"/>
+ </imageobject>
+ <imageobject role="html">
+ <imagedata fileref="images/nested-booking.png" align="center"/>
+ </imageobject>
+ </mediaobject>
+
+ <para>The user now has the option to select any available room to be included in the booking. As with the
+hotel booking application we saw previously, this can lead to issues with state consistency. As with storing state
+in the <varname>HTTPSession</varname>, if a conversation variable changes it affects all windows operating within
+the same conversation context.</para>
+
+ <para>To demonstrate this, let’s suppose the user clones the room selection screen in a new window. The
+user then selects the <emphasis>Wonderful Room</emphasis> and proceeds to the confirmation screen. To see just how much
+it would cost to live the high-life, the user returns to the original window, selects the <emphasis>Fantastic
+Suite</emphasis> for booking, and again proceeds to confirmation. After reviewing the total cost, the user decides
+that practicality wins out and returns to the window showing <emphasis>Wonderful Room</emphasis> to confirm.</para>
+
+ <para>In this scenario, if we simply store all state in the conversation, we are not protected from
+multi-window operation within the same conversation. Nested conversations allow us to achieve correct behavior even
+when context can vary within the same conversation.</para>
+ </section>
+
+ <section>
+ <title>Understanding Nested Conversations</title>
+
+ <para>Now let's see how the nested booking example extends the behavior of the hotel booking application through
+use of nested conversations. Again, we can read the class from top to bottom, as if it were a story.</para>
+
+ <example>
+ <title>RoomPreferenceAction.java</title>
+ <!-- Can't use code hightlighting with callouts -->
+ <programlistingco>
+ <areaspec>
+ <area id="nested-booking-load-rooms" coords="25"/>
+ <area id="nested-booking-nested-conversation" coords="38"/>
+ <area id="nested-booking-select-preference" coords="43"/>
+ <area id="nested-booking-end-annotation" coords="58"/>
+ </areaspec>
+ <programlisting><![CDATA[@Stateful
+@Name("roomPreference")
+@Restrict("#{identity.loggedIn}")
+public class RoomPreferenceAction implements RoomPreference
+{
+
+ @Logger
+ private Log log;
+
+ @In private Hotel hotel;
+
+ @In private Booking booking;
+
+ @DataModel(value="availableRooms")
+ private List<Room> availableRooms;
+
+ @DataModelSelection(value="availableRooms")
+ private Room roomSelection;
+
+ @In(required=false, value="roomSelection")
+ @Out(required=false, value="roomSelection")
+ private Room room;
+
+ @Factory("availableRooms")
+ public void loadAvailableRooms()
+ {
+ availableRooms = hotel.getAvailableRooms(booking.getCheckinDate(), booking.getCheckoutDate());
+ log.info("Retrieved #0 available rooms", availableRooms.size());
+ }
+
+ public BigDecimal getExpectedPrice()
+ {
+ log.info("Retrieving price for room #0", roomSelection.getName());
+
+ return booking.getTotal(roomSelection);
+ }
+
+ @Begin(nested=true)
+ public String selectPreference()
+ {
+ log.info("Room selected");
+
+ this.room = this.roomSelection;
+
+ return "payment";
+ }
+
+ public String requestConfirmation()
+ {
+ // all validations are performed through the s:validateAll, so checks are already
+ // performed
+ log.info("Request confirmation from user");
+
+ return "confirm";
+ }
+
+ @End(beforeRedirect=true)
+ public String cancel()
+ {
+ log.info("ending conversation");
+
+ return "cancel";
+ }
+
+ @Destroy @Remove
+ public void destroy() {}
+}
+]]></programlisting>
+ <calloutlist>
+ <callout arearefs="nested-booking-load-rooms">
+ <para> The <varname>hotel</varname> instance is injected from the conversation context. The hotel
+ is loaded through an <emphasis>extended persistence context</emphasis> so that the entity
+ remains managed throughout the conversation. This allows us to lazily load the
+ <varname>availableRooms</varname> through an <varname>@Factory</varname> method by
+ simply walking the assocation.
+ </para>
+ </callout>
+ <callout arearefs="nested-booking-nested-conversation">
+ <para> When <link linkend="begin-annotation">
+ <literal>@Begin(nested=true)</literal>
+ </link> is encountered, a nested conversation is pushed onto the conversation stack. When
+ executing within a nested conversation, components still have access to all outer conversation
+ state, but setting any values in the nested conversation’s state container does not affect
+ the outer conversation. In addition, nested conversations can exist concurrently stacked on the
+ same outer conversation, allowing independent state for each.</para>
+ </callout>
+ <callout arearefs="nested-booking-select-preference">
+ <para>The <varname>roomSelection</varname> is outjected to the conversation based on the
+ <varname>@DataModelSelection</varname>. Note that because the nested conversation has an
+ independent context, the <varname>roomSelection</varname> is only set into the new nested
+ conversation. Should the user select a different preference in another window or tab a new
+ nested conversation would be started.</para>
+ </callout>
+ <callout arearefs="nested-booking-end-annotation">
+ <para> The <link linkend="end-annotation">
+ <literal>@End</literal>
+ </link> annotation pops the conversation stack and resumes the outer conversation. The
+ <varname>roomSelection</varname> is destroyed along with the conversation context.</para>
+ </callout>
+ </calloutlist>
+ </programlistingco>
+ </example>
+
+ <para>When we being a nested conversation it is pushed onto the conversation stack. In the <varname>nestedbooking</varname>
+example, the conversation stack consists of the outer long-running conversation (the booking) and each of the nested conversations (room
+selections).</para>
+
+ <example>
+ <title>rooms.xhtml</title>
+ <!-- Can't use code hightlighting with callouts -->
+ <programlistingco>
+ <areaspec>
+ <area id="nested-booking-available-rooms" coords="19"/>
+ <area id="nested-booking-selection-action" coords="36"/>
+ <area id="nested-booking-cancel-action" coords="45"/>
+ </areaspec>
+ <programlisting><![CDATA[<div class="section">
+ <h1>Room Preference</h1>
+</div>
+
+<div class="section">
+ <h:form id="room_selections_form">
+ <div class="section">
+ <h:outputText styleClass="output"
+ value="No rooms available for the dates selected: "
+ rendered="#{availableRooms != null and availableRooms.rowCount == 0}"/>
+ <h:outputText styleClass="output"
+ value="Rooms available for the dates selected: "
+ rendered="#{availableRooms != null and availableRooms.rowCount > 0}"/>
+
+ <h:outputText styleClass="output" value="#{booking.checkinDate}"/> -
+ <h:outputText styleClass="output" value="#{booking.checkoutDate}"/>
+
+ <br/><br/>
+
+ <h:dataTable value="#{availableRooms}" var="room"
+ rendered="#{availableRooms.rowCount > 0}">
+ <h:column>
+ <f:facet name="header">Name</f:facet>
+ #{room.name}
+ </h:column>
+ <h:column>
+ <f:facet name="header">Description</f:facet>
+ #{room.description}
+ </h:column>
+ <h:column>
+ <f:facet name="header">Per Night</f:facet>
+ <h:outputText value="#{room.price}">
+ <f:convertNumber type="currency" currencySymbol="$"/>
+ </h:outputText>
+ </h:column>
+ <h:column>
+ <f:facet name="header">Action</f:facet>
+ <h:commandLink id="selectRoomPreference"
+ action="#{roomPreference.selectPreference}">Select</h:commandLink>
+ </h:column>
+ </h:dataTable>
+ </div>
+ <div class="entry">
+ <div class="label"> </div>
+ <div class="input">
+ <s:button id="cancel" value="Revise Dates" view="/book.xhtml"/>
+ </div>
+ </div>
+ </h:form>
+</div>
+]]></programlisting>
+ <calloutlist>
+ <callout arearefs="nested-booking-available-rooms">
+ <para>When requested from EL, the <varname>#{availableRooms}</varname> are loaded by the <varname>@Factory</varname>
+method defined in <varname>RoomPreferenceAction</varname>. The <varname>@Factory</varname> method will only be executed once to load the values
+into the current context as a <link linkend="datamodel-annotation">
+ <varname>@DataModel</varname>
+</link> instance.</para>
+ </callout>
+ <callout arearefs="nested-booking-selection-action">
+ <para>Invoking the <varname>#{roomPreference.selectPreference}</varname> action results in the row being selected
+and set into the <varname>@DataModelSelection</varname>. This value is then outjected to the nested conversation context.</para>
+ </callout>
+ <callout arearefs="nested-booking-cancel-action">
+ <para>Revising the dates simply returns to the <varname>/book.xhtml</varname>. Note that we have not yet nested
+a conversation (no room preference has been selected), so the current conversation can simply be resumed. The <varname><s:button></varname>
+component simply propagates the current conversation when displaying the <varname>/book.xhtml</varname> view.</para>
+ </callout>
+ </calloutlist>
+ </programlistingco>
+ </example>
+
+ <para>Now that we have seen how to nest a conversation, let's see how we can confirm the booking once a room has been selected. This
+can be achieved by simply extending the behavior of the <varname>HotelBookingAction</varname>.</para>
+
+ <example>
+ <title>HotelBookingAction.java</title>
+ <!-- Can't use code hightlighting with callouts -->
+ <programlistingco>
+ <areaspec>
+ <area id="nested-booking-end-root" coords="77"/>
+ <area id="nested-booking-confirm" coords="82"/>
+ <area id="nested-booking-cancel" coords="89" />
+ </areaspec>
+ <programlisting><![CDATA[@Stateful
+@Name("hotelBooking")
+@Restrict("#{identity.loggedIn}")
+public class HotelBookingAction implements HotelBooking
+{
+
+ @PersistenceContext(type=EXTENDED)
+ private EntityManager em;
+
+ @In
+ private User user;
+
+ @In(required=false) @Out
+ private Hotel hotel;
+
+ @In(required=false)
+ @Out(required=false)
+ private Booking booking;
+
+ @In(required=false)
+ private Room roomSelection;
+
+ @In
+ private FacesMessages facesMessages;
+
+ @In
+ private Events events;
+
+ @Logger
+ private Log log;
+
+ @Begin
+ public void selectHotel(Hotel selectedHotel)
+ {
+ log.info("Selected hotel #0", selectedHotel.getName());
+ hotel = em.merge(selectedHotel);
+ }
+
+ public String setBookingDates()
+ {
+ // the result will indicate whether or not to begin the nested conversation
+ // as well as the navigation. if a null result is returned, the nested
+ // conversation will not begin, and the user will be returned to the current
+ // page to fix validation issues
+ String result = null;
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.add(Calendar.DAY_OF_MONTH, -1);
+
+ // validate what we have received from the user so far
+ if ( booking.getCheckinDate().before( calendar.getTime() ) )
+ {
+ facesMessages.addToControl("checkinDate", "Check in date must be a future date");
+ }
+ else if ( !booking.getCheckinDate().before( booking.getCheckoutDate() ) )
+ {
+ facesMessages.addToControl("checkoutDate", "Check out date must be later than check in date");
+ }
+ else
+ {
+ result = "rooms";
+ }
+
+ return result;
+ }
+
+ public void bookHotel()
+ {
+ booking = new Booking(hotel, user);
+ Calendar calendar = Calendar.getInstance();
+ booking.setCheckinDate( calendar.getTime() );
+ calendar.add(Calendar.DAY_OF_MONTH, 1);
+ booking.setCheckoutDate( calendar.getTime() );
+ }
+
+ @End(root=true)
+ public void confirm()
+ {
+ // on confirmation we set the room preference in the booking. the room preference
+ // will be injected based on the nested conversation we are in.
+ booking.setRoomPreference(roomSelection);
+
+ em.persist(booking);
+ facesMessages.add("Thank you, #{user.name}, your confimation number for #{hotel.name} is #{booking.id}");
+ log.info("New booking: #{booking.id} for #{user.username}");
+ events.raiseTransactionSuccessEvent("bookingConfirmed");
+ }
+
+ @End(root=true, beforeRedirect=true)
+ public void cancel() {}
+
+ @Destroy @Remove
+ public void destroy() {}
+}
+]]></programlisting>
+ <calloutlist>
+ <callout arearefs="nested-booking-end-root">
+ <para>Annotating an action with <link linkend="end-annotation">
+ <varname>@End(root=true)</varname>
+ </link> ends the root conversation which effectively destroys the entire conversation stack.
+ When any conversation is ended, it's nested conversations are ended as well. As the root is
+ the conversation that started it all, this is a simple way to destroy and release all state
+ associated with a workspace once the booking is confirmed.</para>
+ </callout>
+ <callout arearefs="nested-booking-confirm">
+ <para>The <varname>roomSelection</varname> is only associated with the <varname>booking</varname>
+ on user confirmation. While outjecting values to the nested conversation context will not
+ impact the outer conversation, any objects injected from the outer conversation are injected
+ by reference. This means that any changing to these objects will be reflected in the parent
+ conversation as well as other concurrent nested conversations.</para>
+ </callout>
+ <callout arearefs="nested-booking-cancel">
+ <para>By simply annotating the cancellation action with <link linkend="end-annotation">
+ <varname>@End(root=true, beforeRedirect=true)</varname>
+ </link>
+ we can easily destroy and release all state associated with the
+ workspace prior to redirecting the user back to the hotel selection view.</para>
+ </callout>
+ </calloutlist>
+ </programlistingco>
+ </example>
+
+ <para>Feel free to deploy the application, open many windows or tabs and attempt combinations of various hotels with
+various room preferences. Confirming a booking always results in the correct hotel and room preference thanks to the nested
+conversation model.</para>
+ </section>
+ </section>
+
<section id="dvdstore">
<title>A complete application featuring Seam and jBPM: the DVD Store example</title>
Added: trunk/doc/Seam_Reference_Guide/en-US/images/nested-booking.png
===================================================================
(Binary files differ)
Property changes on: trunk/doc/Seam_Reference_Guide/en-US/images/nested-booking.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
16 years, 2 months
Seam SVN: r9289 - trunk/examples/nestedbooking/src/org/jboss/seam/example/booking.
by seam-commits@lists.jboss.org
Author: jacob.orshalick
Date: 2008-10-13 22:02:05 -0400 (Mon, 13 Oct 2008)
New Revision: 9289
Modified:
trunk/examples/nestedbooking/src/org/jboss/seam/example/booking/RoomPreferenceAction.java
Log:
JBSEAM-2295 cleanup to make the example easier to understand
Modified: trunk/examples/nestedbooking/src/org/jboss/seam/example/booking/RoomPreferenceAction.java
===================================================================
--- trunk/examples/nestedbooking/src/org/jboss/seam/example/booking/RoomPreferenceAction.java 2008-10-13 23:14:57 UTC (rev 9288)
+++ trunk/examples/nestedbooking/src/org/jboss/seam/example/booking/RoomPreferenceAction.java 2008-10-14 02:02:05 UTC (rev 9289)
@@ -19,6 +19,8 @@
import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.log.Log;
+import org.jboss.seam.example.booking.Room;
+
@Stateful
@Name("roomPreference")
@Restrict("#{identity.loggedIn}")
@@ -28,21 +30,19 @@
@Logger
private Log log;
- @In(required=false)
- @Out
- private Hotel hotel;
+ @In private Hotel hotel;
+
+ @In private Booking booking;
- @In(required=false)
- @Out(required=false)
- private Booking booking;
-
@DataModel(value="availableRooms")
private List<Room> availableRooms;
@DataModelSelection(value="availableRooms")
+ private Room roomSelection;
+
@In(required=false, value="roomSelection")
@Out(required=false, value="roomSelection")
- private Room roomSelection;
+ private Room room;
@Factory("availableRooms")
public void loadAvailableRooms()
@@ -61,10 +61,10 @@
@Begin(nested=true)
public String selectPreference()
{
- // seam takes care of everything for us here. we don't have to do anything other
- // than send the appropriate outcome to forward to the payment screen.
log.info("Room selected");
+ this.room = this.roomSelection;
+
return "payment";
}
16 years, 2 months
Seam SVN: r9288 - trunk/doc/Seam_Reference_Guide/en-US.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-10-13 19:14:57 -0400 (Mon, 13 Oct 2008)
New Revision: 9288
Modified:
trunk/doc/Seam_Reference_Guide/en-US/Security.xml
Log:
JBSEAM-3549
Modified: trunk/doc/Seam_Reference_Guide/en-US/Security.xml
===================================================================
--- trunk/doc/Seam_Reference_Guide/en-US/Security.xml 2008-10-13 23:14:34 UTC (rev 9287)
+++ trunk/doc/Seam_Reference_Guide/en-US/Security.xml 2008-10-13 23:14:57 UTC (rev 9288)
@@ -445,6 +445,19 @@
That is all that is required - automatic authentication will now occur for users revisiting your site (as long as they
check the "remember me" checkbox).
</para>
+
+ <para>
+ To ensure that users are automatically authenticated when returning to the site, the following section
+ should be placed in components.xml:
+ </para>
+
+ <programlisting role="XML"><![CDATA[ <event type="org.jboss.seam.security.notLoggedIn">
+ <action execute="#{redirect.captureCurrentView}"/>
+ <action execute="#{identity.tryLogin()}"/>
+ </event>
+ <event type="org.jboss.seam.security.loginSuccessful">
+ <action execute="#{redirect.returnToCapturedView}"/>
+ </event>]]></programlisting>
</sect3>
16 years, 2 months
Seam SVN: r9287 - trunk.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-10-13 19:14:34 -0400 (Mon, 13 Oct 2008)
New Revision: 9287
Modified:
trunk/seam21migration.txt
Log:
JBSEAM-3549
Modified: trunk/seam21migration.txt
===================================================================
--- trunk/seam21migration.txt 2008-10-13 22:46:22 UTC (rev 9286)
+++ trunk/seam21migration.txt 2008-10-13 23:14:34 UTC (rev 9287)
@@ -90,6 +90,18 @@
have been set. Instead, it will simply return true if the user is currently authenticated. If you
require the previous behaviour, then please use Identity.tryLogin() instead.
+If you are using the token-based "Remember Me" feature of Seam Security, you will need to add the following
+section to components.xml to ensure that the user is automatically logged in when first accessing the
+application:
+
+ <event type="org.jboss.seam.security.notLoggedIn">
+ <action execute="#{redirect.captureCurrentView}"/>
+ <action execute="#{identity.tryLogin()}"/>
+ </event>
+ <event type="org.jboss.seam.security.loginSuccessful">
+ <action execute="#{redirect.returnToCapturedView}"/>
+ </event>
+
PDF (iText)
--------
16 years, 2 months
Seam SVN: r9286 - in trunk/src: main/org/jboss/seam/exception and 4 other directories.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2008-10-13 18:46:22 -0400 (Mon, 13 Oct 2008)
New Revision: 9286
Modified:
trunk/src/main/org/jboss/seam/bpm/Jbpm.java
trunk/src/main/org/jboss/seam/bpm/PageflowDeploymentHandler.java
trunk/src/main/org/jboss/seam/exception/Exceptions.java
trunk/src/main/org/jboss/seam/init/Initialization.java
trunk/src/main/org/jboss/seam/navigation/Pages.java
trunk/src/main/org/jboss/seam/util/Resources.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UISignature.java
Log:
JBSEAM-3500
Modified: trunk/src/main/org/jboss/seam/bpm/Jbpm.java
===================================================================
--- trunk/src/main/org/jboss/seam/bpm/Jbpm.java 2008-10-13 21:54:29 UTC (rev 9285)
+++ trunk/src/main/org/jboss/seam/bpm/Jbpm.java 2008-10-13 22:46:22 UTC (rev 9286)
@@ -35,6 +35,7 @@
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
import org.jboss.seam.util.Naming;
+import org.jboss.seam.util.Resources;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.graph.def.ProcessDefinition;
@@ -165,6 +166,8 @@
catch (JpdlException e)
{
throw new JpdlException("Unable to parse process definition " + resourceName, e);
+ } finally {
+ Resources.closeStream(resource);
}
}
@@ -175,7 +178,12 @@
{
throw new IllegalArgumentException("process definition resource not found: " + resourceName);
}
- return ProcessDefinition.parseXmlInputStream(resource);
+
+ try {
+ return ProcessDefinition.parseXmlInputStream(resource);
+ } finally {
+ Resources.closeStream(resource);
+ }
}
public String[] getPageflowDefinitions()
@@ -216,7 +224,13 @@
*/
public ProcessDefinition getPageflowDefinitionFromXml(String pageflowDefinition)
{
- return Jbpm.parseInputSource( new InputSource( new ReaderInputStream( new StringReader(pageflowDefinition) ) ) );
+ InputStream stream = null;
+ try {
+ stream = new ReaderInputStream(new StringReader(pageflowDefinition));
+ return Jbpm.parseInputSource(new InputSource(stream));
+ } finally {
+ Resources.closeStream(stream);
+ }
}
/**
@@ -226,7 +240,13 @@
*/
public ProcessDefinition getProcessDefinitionFromXml(String processDefinition)
{
- return ProcessDefinition.parseXmlInputStream( new ReaderInputStream( new StringReader(processDefinition) ) );
+ InputStream stream = null;
+ try {
+ stream = new ReaderInputStream(new StringReader(processDefinition));
+ return ProcessDefinition.parseXmlInputStream(stream);
+ } finally {
+ Resources.closeStream(stream);
+ }
}
/**
Modified: trunk/src/main/org/jboss/seam/bpm/PageflowDeploymentHandler.java
===================================================================
--- trunk/src/main/org/jboss/seam/bpm/PageflowDeploymentHandler.java 2008-10-13 21:54:29 UTC (rev 9285)
+++ trunk/src/main/org/jboss/seam/bpm/PageflowDeploymentHandler.java 2008-10-13 22:46:22 UTC (rev 9286)
@@ -35,21 +35,20 @@
public void handle(String name, ClassLoader classLoader)
{
- if (name.endsWith(".jpdl.xml"))
- {
+ if (name.endsWith(".jpdl.xml")) {
InputStream inputStream = Resources.getResourceAsStream(name, null);
- try
- {
+ try {
Element root = XML.getRootElementSafely(inputStream);
if ("pageflow-definition".equals(root.getName()))
{
pageflowDefinitions.add(name);
}
- }
- catch (DocumentException e)
- {
+ } catch (DocumentException e) {
log.debug("Unable to parse " + name, e);
+ } finally {
+ Resources.closeStream(inputStream);
}
+
}
}
Modified: trunk/src/main/org/jboss/seam/exception/Exceptions.java
===================================================================
--- trunk/src/main/org/jboss/seam/exception/Exceptions.java 2008-10-13 21:54:29 UTC (rev 9285)
+++ trunk/src/main/org/jboss/seam/exception/Exceptions.java 2008-10-13 22:46:22 UTC (rev 9286)
@@ -28,6 +28,7 @@
import org.jboss.seam.log.Logging;
import org.jboss.seam.navigation.Pages;
import org.jboss.seam.util.Reflections;
+import org.jboss.seam.util.Resources;
import org.jboss.seam.util.Strings;
import org.jboss.seam.util.XML;
@@ -147,8 +148,15 @@
InputStream stream = ResourceLoader.instance().getResourceAsStream(fileName);
if (stream!=null)
{
- log.debug("reading exception mappings from " + fileName);
- List<Element> elements = XML.getRootElement(stream).elements("exception");
+ log.debug("reading exception mappings from " + fileName);
+
+ List<Element> elements = null;
+ try {
+ elements = XML.getRootElement(stream).elements("exception");
+ } finally {
+ Resources.closeStream(stream);
+ }
+
for (final Element exception: elements)
{
String className = exception.attributeValue("class");
Modified: trunk/src/main/org/jboss/seam/init/Initialization.java
===================================================================
--- trunk/src/main/org/jboss/seam/init/Initialization.java 2008-10-13 21:54:29 UTC (rev 9285)
+++ trunk/src/main/org/jboss/seam/init/Initialization.java 2008-10-13 22:46:22 UTC (rev 9286)
@@ -186,20 +186,20 @@
seenDocuments.addAll(documentNames);
}
- if (!skip)
- {
- try
- {
+ if (!skip) {
+ try{
+ InputStream stream = url.openStream();
+
log.debug("reading " + url);
- installComponentsFromXmlElements( XML.getRootElement( url.openStream() ), replacements );
- }
- catch (Exception e)
- {
+ try {
+ installComponentsFromXmlElements(XML.getRootElement(stream), replacements);
+ } finally {
+ Resources.closeStream(stream);
+ }
+ } catch (Exception e) {
throw new RuntimeException("error while reading " + url, e);
}
- }
- else
- {
+ } else {
log.trace("skipping read of duplicate components.xml " + url);
}
}
@@ -219,22 +219,26 @@
catch (Exception e)
{
throw new RuntimeException("error while reading /WEB-INF/components.xml", e);
+ } finally {
+ Resources.closeStream(stream);
}
}
}
private Properties getReplacements()
{
- try
- {
+ InputStream replaceStream = null;
+ try {
Properties replacements = new Properties();
- InputStream replaceStream = Resources.getResourceAsStream("/components.properties", servletContext);
- if (replaceStream != null) replacements.load(replaceStream);
+ replaceStream = Resources.getResourceAsStream("/components.properties", servletContext);
+ if (replaceStream != null) {
+ replacements.load(replaceStream);
+ }
return replacements;
- }
- catch (IOException ioe)
- {
+ } catch (IOException ioe) {
throw new RuntimeException("error reading components.properties", ioe);
+ } finally {
+ Resources.closeStream(replaceStream);
}
}
@@ -908,10 +912,10 @@
classFilenameFromDescriptor(fileName),
replacements);
}
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
throw new RuntimeException("error while reading " + fileName, e);
+ } finally {
+ Resources.closeStream(stream);
}
}
}
@@ -1021,13 +1025,9 @@
log.error("could not read " + resource, ioe);
}
}
- finally
+ finally
{
- try
- {
- stream.close();
- }
- catch (IOException ex) { } // swallow
+ Resources.closeStream(stream);
}
}
else
Modified: trunk/src/main/org/jboss/seam/navigation/Pages.java
===================================================================
--- trunk/src/main/org/jboss/seam/navigation/Pages.java 2008-10-13 21:54:29 UTC (rev 9285)
+++ trunk/src/main/org/jboss/seam/navigation/Pages.java 2008-10-13 22:46:22 UTC (rev 9286)
@@ -57,6 +57,7 @@
import org.jboss.seam.pageflow.Pageflow;
import org.jboss.seam.security.Identity;
import org.jboss.seam.security.NotLoggedInException;
+import org.jboss.seam.util.Resources;
import org.jboss.seam.util.Strings;
import org.jboss.seam.util.XML;
import org.jboss.seam.web.Parameters;
@@ -120,7 +121,11 @@
log.info("no pages.xml file found: " + resource);
} else {
log.debug("reading pages.xml file: " + resource);
- parse(stream);
+ try {
+ parse(stream);
+ } finally {
+ Resources.closeStream(stream);
+ }
}
}
@@ -153,7 +158,11 @@
else
{
log.debug("reading pages.xml file: " + fileName);
- parse(stream,viewId);
+ try {
+ parse(stream,viewId);
+ } finally {
+ Resources.closeStream(stream);
+ }
}
}
}
Modified: trunk/src/main/org/jboss/seam/util/Resources.java
===================================================================
--- trunk/src/main/org/jboss/seam/util/Resources.java 2008-10-13 21:54:29 UTC (rev 9285)
+++ trunk/src/main/org/jboss/seam/util/Resources.java 2008-10-13 22:46:22 UTC (rev 9286)
@@ -1,14 +1,18 @@
package org.jboss.seam.util;
+import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import javax.servlet.ServletContext;
import org.jboss.seam.Seam;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
public class Resources
{
+ private static final LogProvider log = Logging.getLogProvider(Resources.class);
public static InputStream getResourceAsStream(String resource, ServletContext servletContext)
{
@@ -17,17 +21,18 @@
InputStream stream = null;
- if (servletContext!=null)
- {
- try
- {
+ if (servletContext!=null) {
+ try {
stream = servletContext.getResourceAsStream(resource);
+ if (stream!=null) {
+ log.debug("Loaded resource from servlet context: " + resource);
+ }
+ } catch (Exception e) {
+ //
}
- catch (Exception e) {}
}
- if (stream==null)
- {
+ if (stream==null) {
stream = getResourceAsStream(resource, stripped);
}
@@ -43,11 +48,12 @@
if (servletContext!=null)
{
- try
- {
+ try {
url = servletContext.getResource(resource);
+ log.debug("Loaded resource from servlet context: " + url);
+ } catch (Exception e) {
+ //
}
- catch (Exception e) {}
}
if (url==null)
@@ -62,38 +68,68 @@
{
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
InputStream stream = null;
- if (classLoader!=null)
- {
+ if (classLoader!=null) {
stream = classLoader.getResourceAsStream(stripped);
+ if (stream !=null) {
+ log.debug("Loaded resource from context classloader: " + stripped);
+ }
}
- if ( stream == null )
- {
+
+ if (stream == null) {
stream = Seam.class.getResourceAsStream(resource);
+ if (stream !=null) {
+ log.debug("Loaded resource from Seam classloader: " + resource);
+ }
}
- if ( stream == null )
- {
+
+ if (stream == null) {
stream = Seam.class.getClassLoader().getResourceAsStream(stripped);
+ if (stream!=null) {
+ log.debug("Loaded resource from Seam classloader: " + stripped);
+ }
}
+
return stream;
}
static URL getResource(String resource, String stripped)
{
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- URL url = null;
- if (classLoader!=null)
- {
- url = classLoader.getResource(stripped);
- }
- if ( url == null )
- {
- url = Seam.class.getResource(resource);
- }
- if ( url == null )
- {
- url = Seam.class.getClassLoader().getResource(stripped);
- }
- return url;
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ URL url = null;
+ if (classLoader!=null) {
+ url = classLoader.getResource(stripped);
+ if (url!=null) {
+ log.debug("Loaded resource from context classloader: " + url);
+ }
+ }
+
+ if (url == null) {
+ url = Seam.class.getResource(resource);
+ if (url!=null) {
+ log.debug("Loaded resource from Seam classloader: " + url);
+ }
+ }
+
+ if (url == null) {
+ url = Seam.class.getClassLoader().getResource(stripped);
+ if (url!=null) {
+ log.debug("Loaded resource from Seam classloader: " + url);
+ }
+ }
+
+ return url;
}
+ public static void closeStream(InputStream inputStream) {
+ if (inputStream == null) {
+ return;
+ }
+
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ //
+ }
+ }
+
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UISignature.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UISignature.java 2008-10-13 21:54:29 UTC (rev 9285)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UISignature.java 2008-10-13 22:46:22 UTC (rev 9286)
@@ -12,6 +12,7 @@
import org.jboss.seam.pdf.ITextUtils;
import org.jboss.seam.pdf.KeyStoreConfig;
import org.jboss.seam.util.FacesResources;
+import org.jboss.seam.util.Resources;
import com.lowagie.text.DocWriter;
import com.lowagie.text.pdf.PdfAcroForm;
@@ -123,11 +124,10 @@
public byte[] sign(byte[] originalBytes)
{
KeyStoreConfig store = KeyStoreConfig.instance();
+ InputStream is = null;
+ try {
+ is = FacesResources.getResourceAsStream(store.getKeyStore(), getFacesContext().getExternalContext());
- try
- {
- InputStream is = FacesResources.getResourceAsStream(store.getKeyStore(), getFacesContext().getExternalContext());
-
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(is, store.getKeyStorePassword().toCharArray());
@@ -148,10 +148,10 @@
stamper.close();
return os.toByteArray();
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
throw new RuntimeException(e);
+ } finally {
+ Resources.closeStream(is);
}
}
16 years, 2 months
Seam SVN: r9285 - in trunk: examples/ui/view and 5 other directories.
by seam-commits@lists.jboss.org
Author: danielc.roth
Date: 2008-10-13 17:54:29 -0400 (Mon, 13 Oct 2008)
New Revision: 9285
Added:
trunk/examples/ui/view/equalityValidatorWConvert.xhtml
trunk/ui/src/main/java/org/jboss/seam/ui/component/UIEqualityValidator.java
trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/EqualityValidatorRendererBase.java
Modified:
trunk/examples/ui/src/org/jboss/seam/example/ui/EqualityValidatorBean.java
trunk/examples/ui/view/equalityValidator.xhtml
trunk/examples/ui/view/template.xhtml
trunk/ui/src/main/config/component/equalityValidator.xml
trunk/ui/src/main/java/org/jboss/seam/ui/util/cdk/Messages.java
trunk/ui/src/main/java/org/jboss/seam/ui/validator/EqualityValidator.java
Log:
JBSEAM-2809
Modified: trunk/examples/ui/src/org/jboss/seam/example/ui/EqualityValidatorBean.java
===================================================================
--- trunk/examples/ui/src/org/jboss/seam/example/ui/EqualityValidatorBean.java 2008-10-13 20:38:08 UTC (rev 9284)
+++ trunk/examples/ui/src/org/jboss/seam/example/ui/EqualityValidatorBean.java 2008-10-13 21:54:29 UTC (rev 9285)
@@ -1,5 +1,7 @@
package org.jboss.seam.example.ui;
+import java.util.Date;
+
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
@@ -13,11 +15,45 @@
public class EqualityValidatorBean
{
- private String name;
-
@In
private StatusMessages statusMessages;
+ private String name;
+
+ private Date date;
+
+ public void check()
+ {
+ if (Strings.isEmpty(name))
+ {
+ statusMessages.addToControl("name", Severity.WARN, "Enter a name!");
+ }
+ else {
+ statusMessages.addToControl("name", Severity.INFO, "OK!");
+ }
+ }
+
+ public void checkDate()
+ {
+ if (date==null)
+ {
+ statusMessages.addToControl("date", Severity.WARN, "Enter a date!");
+ }
+ else {
+ statusMessages.addToControl("date", Severity.INFO, "OK!");
+ }
+ }
+
+ public Date getDate()
+ {
+ return date;
+ }
+
+ public void setDate(Date date)
+ {
+ this.date = date;
+ }
+
public String getName()
{
return name;
@@ -28,12 +64,4 @@
this.name = name;
}
- public void check()
- {
- if (Strings.isEmpty(name))
- {
- statusMessages.addToControl("name", Severity.WARN, "Enter a name!");
- }
- }
-
}
Modified: trunk/examples/ui/view/equalityValidator.xhtml
===================================================================
--- trunk/examples/ui/view/equalityValidator.xhtml 2008-10-13 20:38:08 UTC (rev 9284)
+++ trunk/examples/ui/view/equalityValidator.xhtml 2008-10-13 21:54:29 UTC (rev 9285)
@@ -7,18 +7,19 @@
template="template.xhtml">
<ui:param name="tagName" value="s:validateEquality" />
<ui:define name="body">
- <p>Validates that two inputs are equal</p>
+ <p>Validates that two java.lang.String inputs are equal</p>
<h:form>
<h:panelGrid columns="3">
<s:label for="name">Name</s:label>
<h:inputText id="name" value="#{equalityValidatorBean.name}" />
<h:message for="name" />
<s:label for="nameVerification">Name Verification</s:label>
- <h:inputText id="nameVerification" value=" ">
- <s:validateEquality for="name" />
+ <h:inputText id="nameVerification">
+ <s:validateEquality for="name" message="Strings do not match!" />
</h:inputText>
<h:message for="nameVerification" />
- <h:commandButton action="#{equalityValidatorBean.check}" value="Check name" />
+ <h:commandButton action="#{equalityValidatorBean.check}"
+ value="Check name" />
</h:panelGrid>
</h:form>
</ui:define>
Added: trunk/examples/ui/view/equalityValidatorWConvert.xhtml
===================================================================
--- trunk/examples/ui/view/equalityValidatorWConvert.xhtml (rev 0)
+++ trunk/examples/ui/view/equalityValidatorWConvert.xhtml 2008-10-13 21:54:29 UTC (rev 9285)
@@ -0,0 +1,31 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:s="http://jboss.com/products/seam/taglib"
+ template="template.xhtml">
+ <ui:param name="tagName" value="s:validateEquality" />
+ <ui:define name="body">
+ <p>Validates that two java.util.Date inputs are equal</p>
+ <h:form>
+ <h:panelGrid columns="3">
+ <s:label for="date">Date (yyyy-MM-dd)</s:label>
+ <h:inputText id="date" value="#{equalityValidatorBean.date}">
+ <f:convertDateTime pattern="yyyy-MM-dd" />
+ </h:inputText>
+ <h:message for="date" />
+ <s:label for="dateVerification">Date Verification (yyyy-MM-dd)</s:label>
+ <h:inputText id="dateVerification">
+ <f:convertDateTime pattern="yyyy-MM-dd" />
+ <s:validateEquality for="date" />
+ </h:inputText>
+ <h:message for="dateVerification" />
+ <h:commandButton action="#{equalityValidatorBean.checkDate}"
+ value="Check date" />
+ </h:panelGrid>
+ </h:form>
+
+
+ </ui:define>
+</ui:composition>
Modified: trunk/examples/ui/view/template.xhtml
===================================================================
--- trunk/examples/ui/view/template.xhtml 2008-10-13 20:38:08 UTC (rev 9284)
+++ trunk/examples/ui/view/template.xhtml 2008-10-13 21:54:29 UTC (rev 9285)
@@ -57,7 +57,7 @@
}
.menu {
- width: 200px;
+ width: 220px;
float: left;
padding: 10px;
}
@@ -102,6 +102,10 @@
<code>s:validateEquality</code>
</s:link></li>
+ <li><s:link view="/equalityValidatorWConvert.xhtml">
+ <code>s:validateEquality(2)</code>
+ </s:link></li>
+
<li><s:span title="#{spanTitle}" style="font-weight:bold">
<code>s:span</code>
</s:span>
Modified: trunk/ui/src/main/config/component/equalityValidator.xml
===================================================================
--- trunk/ui/src/main/config/component/equalityValidator.xml 2008-10-13 20:38:08 UTC (rev 9284)
+++ trunk/ui/src/main/config/component/equalityValidator.xml 2008-10-13 21:54:29 UTC (rev 9285)
@@ -1,16 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN" "http://jboss.org/jbossrichfaces/component-config.dtd" >
<components>
- <validator generate="false">
- <id>org.jboss.seam.ui.EqualityValidator</id>
- <classname>org.jboss.seam.ui.validator.EqualityValidator</classname>
+
+ <component>
+ <name>org.jboss.seam.ui.EqualityValidator</name>
+ <family>org.jboss.seam.ui.EqualityValidator</family>
+ <classname>org.jboss.seam.ui.component.html.HtmlEqualityValidator</classname>
+ <superclass>org.jboss.seam.ui.component.UIEqualityValidator</superclass>
<description>
- <![CDATA[Validate that the value of two components are equal]]>
+ <![CDATA[Validate all child JSF input fields against the bound propertys using Hibernate Validator.]]>
</description>
+ <renderer generate="false" override="false">
+ <name>org.jboss.seam.ui.EqualityValidatorRenderer</name>
+ <classname>org.jboss.seam.ui.renderkit.EqualityValidatorRendererBase</classname>
+ </renderer>
<tag>
<name>validateEquality</name>
- <classname>org.jboss.seam.ui.taglib.ModelValidatorTag</classname>
- <superclass>javax.faces.webapp.ValidatorELTag</superclass>
+ <classname>org.jboss.seam.ui.taglib.EqualityValidatorTag</classname>
+ <superclass>
+ org.jboss.seam.ui.util.cdk.UIComponentTagBase
+ </superclass>
</tag>
- </validator>
+ <property>
+ <name>for</name>
+ <classname>java.lang.String</classname>
+ <description>Id of component to validate against</description>
+ </property>
+ <property>
+ <name>message</name>
+ <classname>java.lang.String</classname>
+ <description>Error message to show</description>
+ </property>
+ <property>
+ <name>messageId</name>
+ <classname>java.lang.String</classname>
+ <description>Message id to use on failure</description>
+ </property>
+
+ </component>
+
</components>
+
Added: trunk/ui/src/main/java/org/jboss/seam/ui/component/UIEqualityValidator.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/component/UIEqualityValidator.java (rev 0)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/component/UIEqualityValidator.java 2008-10-13 21:54:29 UTC (rev 9285)
@@ -0,0 +1,25 @@
+package org.jboss.seam.ui.component;
+
+import javax.faces.component.UIComponentBase;
+
+/**
+ * UIComponent for validator
+ *
+ * @author Daniel Roth
+ */
+public abstract class UIEqualityValidator extends UIComponentBase
+{
+
+ public abstract String getFor();
+
+ public abstract void setFor(String forId);
+
+ public abstract String getMessage();
+
+ public abstract void setMessage(String message);
+
+ public abstract String getMessageId();
+
+ public abstract void setMessageId(String messageId);
+
+}
Added: trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/EqualityValidatorRendererBase.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/EqualityValidatorRendererBase.java (rev 0)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/EqualityValidatorRendererBase.java 2008-10-13 21:54:29 UTC (rev 9285)
@@ -0,0 +1,70 @@
+package org.jboss.seam.ui.renderkit;
+
+import java.io.IOException;
+
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.validator.Validator;
+
+import org.jboss.seam.ui.component.UIEqualityValidator;
+import org.jboss.seam.ui.util.cdk.RendererBase;
+import org.jboss.seam.ui.validator.EqualityValidator;
+
+/**
+ * This class mainly does some validation "hook-in"
+ *
+ * @author Daniel Roth
+ *
+ */
+public class EqualityValidatorRendererBase extends RendererBase
+{
+
+ @Override
+ protected Class getComponentClass()
+ {
+ return UIEqualityValidator.class;
+ }
+
+ @Override
+ protected void doEncodeChildren(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException
+ {
+ UIEqualityValidator ev = (UIEqualityValidator) component;
+ EditableValueHolder evh = null;
+ if (ev != null && ev.getParent() instanceof EditableValueHolder)
+ {
+ evh = (EditableValueHolder) ev.getParent();
+ }
+
+ if (evh == null)
+ throw new IllegalArgumentException("validateEquality tag must be nested in an EditableValueHolder (\"input tag\")");
+
+ if (!hasEqualityValidator(evh))
+ {
+ evh.addValidator(new EqualityValidator(ev.getFor(), ev.getMessage(), ev.getMessageId()));
+ evh.setRequired(true);
+ }
+
+ renderChildren(context, component);
+ }
+
+ private boolean hasEqualityValidator(EditableValueHolder evh)
+ {
+ for (Validator validator : evh.getValidators())
+ {
+ if (validator instanceof EqualityValidator)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean getRendersChildren()
+ {
+ return true;
+ }
+
+}
Modified: trunk/ui/src/main/java/org/jboss/seam/ui/util/cdk/Messages.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/util/cdk/Messages.java 2008-10-13 20:38:08 UTC (rev 9284)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/util/cdk/Messages.java 2008-10-13 21:54:29 UTC (rev 9285)
@@ -13,7 +13,7 @@
private static synchronized ResourceBundle getBundle() {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
- ResourceBundle bundle = (ResourceBundle) bundles.get(contextClassLoader);
+ ResourceBundle bundle = bundles.get(contextClassLoader);
if (bundle == null) {
bundle = ResourceBundle.getBundle(BUNDLE_NAME, Locale.getDefault(), contextClassLoader);
bundles.put(contextClassLoader, bundle);
Modified: trunk/ui/src/main/java/org/jboss/seam/ui/validator/EqualityValidator.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/validator/EqualityValidator.java 2008-10-13 20:38:08 UTC (rev 9284)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/validator/EqualityValidator.java 2008-10-13 21:54:29 UTC (rev 9285)
@@ -22,34 +22,34 @@
* Validate two fields are equal
*
* @author pmuir
- *
+ * @author Daniel Roth
+ *
*/
public class EqualityValidator implements Validator, StateHolder
{
-
+
private static LogProvider log = Logging.getLogProvider(EqualityValidator.class);
-
+
public static final String MESSAGE_ID = "org.jboss.seam.ui.validator.NOT_EQUAL";
-
+
public static final String VALIDATOR_ID = "org.jboss.seam.ui.validator.Equality";
private String forId;
-
private String message;
private String messageId;
-
- public EqualityValidator()
+
+ public EqualityValidator()
{
- this.message = "Value does not equal that in #0";
+ this.message = "Value does not equal that in '#0'";
this.messageId = MESSAGE_ID;
}
-
+
public EqualityValidator(String forId)
{
this();
setFor(forId);
}
-
+
public EqualityValidator(String forId, String message, String messageId)
{
this(forId);
@@ -62,13 +62,9 @@
setMessageId(messageId);
}
}
-
+
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
{
- if (!(component instanceof EditableValueHolder))
- {
- throw new FacesException("Must attach an equality validator to an input component");
- }
String forId = getFor();
if (forId == null)
{
@@ -89,32 +85,32 @@
}
}
}
-
+
public String getFor()
{
return forId;
- }
-
+ }
+
public void setFor(String forId)
{
this.forId = forId;
}
-
+
public String getMessage()
{
return message;
}
-
+
public void setMessage(String message)
{
this.message = message;
}
-
+
public String getMessageId()
{
return messageId;
}
-
+
public void setMessageId(String messageId)
{
this.messageId = messageId;
@@ -127,7 +123,7 @@
public void restoreState(FacesContext context, Object state)
{
- Object[] fields = (Object []) state;
+ Object[] fields = (Object[]) state;
forId = (String) fields[0];
message = (String) fields[1];
messageId = (String) fields[2];
@@ -147,22 +143,22 @@
// No-op
}
-
/**
- * Simple data strcuture to hold info on the "other" component
+ * Simple data structure to hold info on the "other" component
+ *
* @author pmuir
- *
+ *
*/
- private class OtherComponent
+ private class OtherComponent
{
-
+
private FacesContext context;
private UIComponent component;
private EditableValueHolder editableValueHolder;
-
+
private Renderer renderer;
private Converter converter;
-
+
public OtherComponent(FacesContext facesContext, UIComponent component)
{
this.component = component;
@@ -175,23 +171,23 @@
initRenderer();
initConverter();
}
-
- private void initRenderer()
+
+ private void initRenderer()
{
if (renderer == null)
{
String rendererType = component.getRendererType();
- if (rendererType != null)
+ if (rendererType != null)
{
renderer = context.getRenderKit().getRenderer(component.getFamily(), rendererType);
- if (null == renderer)
+ if (null == renderer)
{
log.trace("Can't get Renderer for type " + rendererType);
}
- }
+ }
else
{
- if (log.isTraceEnabled())
+ if (log.isTraceEnabled())
{
String id = component.getId();
id = (null != id) ? id : component.getClass().getName();
@@ -200,89 +196,106 @@
}
}
}
-
- private void initConverter() {
+
+ private void initConverter()
+ {
converter = editableValueHolder.getConverter();
- if (converter != null) {
- return;
+ if (converter != null)
+ {
+ return;
}
ValueExpression valueExpression = component.getValueExpression("value");
- if (valueExpression == null) {
- return;
+ if (valueExpression == null)
+ {
+ return;
}
Class converterType;
- try {
- converterType = valueExpression.getType(context.getELContext());
+ try
+ {
+ converterType = valueExpression.getType(context.getELContext());
}
- catch (ELException e) {
- throw new FacesException(e);
+ catch (ELException e)
+ {
+ throw new FacesException(e);
}
// if converterType is null, String, or Object, assume
// no conversion is needed
- if (converterType == null || converterType == String.class || converterType == Object.class)
+ if (converterType == null || converterType == String.class || converterType == Object.class)
{
- return;
+ return;
}
// if getType returns a type for which we support a default
// conversion, acquire an appropriate converter instance.
- try
+ try
{
- Application application = context.getApplication();
- converter = application.createConverter(converterType);
+ Application application = context.getApplication();
+ converter = application.createConverter(converterType);
}
- catch (Exception e)
+ catch (Exception e)
{
throw new FacesException(e);
}
}
-
- private Object getConvertedValue(Object newSubmittedValue) throws ConverterException
+
+ private Object getConvertedValue(Object newSubmittedValue) throws ConverterException
{
-
+
Object newValue;
- if (renderer != null)
+ if (renderer != null)
{
newValue = renderer.getConvertedValue(context, component, newSubmittedValue);
- }
- else if (newSubmittedValue instanceof String)
+ }
+ else if (newSubmittedValue instanceof String)
{
- // If there's no Renderer, and we've got a String, run it through the Converter (if any)
- if (converter != null) {
- newValue = converter.getAsObject(context, component,
- (String) newSubmittedValue);
- }
+ // If there's no Renderer, and we've got a String, run it through
+ // the Converter (if any)
+ if (converter != null)
+ {
+ newValue = converter.getAsObject(context, component, (String) newSubmittedValue);
+ }
else
{
newValue = newSubmittedValue;
}
- }
- else
+ }
+ else
{
newValue = newSubmittedValue;
}
return newValue;
}
-
+
public Object getValue()
{
+ /**
+ * If conversion already is done, return value
+ */
+ if (editableValueHolder.isLocalValueSet())
+ {
+ return editableValueHolder.getValue();
+ }
+
+ /**
+ * Convert submittet value
+ */
Object submittedValue = editableValueHolder.getLocalValue();
- if (submittedValue == null)
+ if (submittedValue == null)
{
return null;
}
Object newValue = null;
- try
+ try
{
newValue = getConvertedValue(submittedValue);
}
- catch (ConverterException ce)
+ catch (ConverterException ce)
{
// Any errors will be attached by JSF
return null;
@@ -290,6 +303,6 @@
return newValue;
}
-
+
}
}
16 years, 2 months