Seam SVN: r12041 - modules/remoting/trunk/docs/en-US.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-02-12 00:56:06 -0500 (Fri, 12 Feb 2010)
New Revision: 12041
Modified:
modules/remoting/trunk/docs/en-US/remoting-model.xml
Log:
completed model API docs
Modified: modules/remoting/trunk/docs/en-US/remoting-model.xml
===================================================================
--- modules/remoting/trunk/docs/en-US/remoting-model.xml 2010-02-11 18:54:05 UTC (rev 12040)
+++ modules/remoting/trunk/docs/en-US/remoting-model.xml 2010-02-12 05:56:06 UTC (rev 12041)
@@ -612,7 +612,39 @@
<section>
<title>Applying Changes</title>
+ <para>
+ Once you have finished making changes to the values in the model, you can apply them with the
+ <literal>applyUpdates()</literal> method. This method scans all of the objects in the model, compares
+ them with their original values and generates a delta which may contain one or more changesets to
+ send to the server. A changeset is simply a list of property value changes for a single object.
+ </para>
+ <para>
+ Like the <literal>fetch()</literal> command you can also specify an action to invoke when applying updates,
+ although the action is invoked <emphasis>after</emphasis> the model updates have been applied. In a
+ typical situation the invoked action would do things like commit a database transaction, end the current
+ conversation, etc.
+ </para>
+
+ <para>
+ Since the <literal>applyUpdates()</literal> method sends an asynchronous request like the
+ <literal>fetch()</literal> and <literal>expand()</literal> methods, we also need to specify a callback
+ function if we wish to do something when the operation completes.
+ </para>
+
+ <programlisting role="XHTML"><![CDATA[ var action = new Seam.Action();
+ .setBeanType("CustomerAction")
+ .setMethod("saveCustomer");
+
+ var callback = function() { alert("Customer saved."); };
+
+ model.applyUpdates(action, callback);]]></programlisting>
+
+ <para>
+ The <literal>applyUpdates()</literal> method performs a refresh of the model, retrieving the latest
+ state of the objects contained in the model after all updates have been applied and the action method
+ (if specified) invoked.
+ </para>
</section>
14 years, 9 months
Seam SVN: r12040 - branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/resteasy.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2010-02-11 13:54:05 -0500 (Thu, 11 Feb 2010)
New Revision: 12040
Added:
branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestEjb.java
branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestEjbLocal.java
Log:
Oooops
Added: branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestEjb.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestEjb.java (rev 0)
+++ branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestEjb.java 2010-02-11 18:54:05 UTC (rev 12040)
@@ -0,0 +1,23 @@
+package org.jboss.seam.example.restbay.resteasy;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+
+@Stateful
+(a)Scope(ScopeType.EVENT)
+@Name("securedEjb")
+public class TestEjb implements TestEjbLocal
+{
+
+ public boolean foo()
+ {
+ return true;
+ }
+
+ @Remove
+ public void remove() {}
+}
Added: branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestEjbLocal.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestEjbLocal.java (rev 0)
+++ branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestEjbLocal.java 2010-02-11 18:54:05 UTC (rev 12040)
@@ -0,0 +1,9 @@
+package org.jboss.seam.example.restbay.resteasy;
+
+import javax.ejb.Local;
+
+@Local
+public interface TestEjbLocal
+{
+ boolean foo();
+}
14 years, 9 months
Seam SVN: r12039 - branches/community/Seam_2_2/examples/ui/resources/WEB-INF.
by seam-commits@lists.jboss.org
Author: mgencur(a)redhat.com
Date: 2010-02-11 10:06:24 -0500 (Thu, 11 Feb 2010)
New Revision: 12039
Modified:
branches/community/Seam_2_2/examples/ui/resources/WEB-INF/pages.xml
Log:
fixed implicit navigation for the example
Modified: branches/community/Seam_2_2/examples/ui/resources/WEB-INF/pages.xml
===================================================================
--- branches/community/Seam_2_2/examples/ui/resources/WEB-INF/pages.xml 2010-02-11 13:28:14 UTC (rev 12038)
+++ branches/community/Seam_2_2/examples/ui/resources/WEB-INF/pages.xml 2010-02-11 15:06:24 UTC (rev 12039)
@@ -11,6 +11,11 @@
<page view-id="/selectItems.xhtml">
<begin-conversation join="true"/>
<param name="personId" converterId="javax.faces.Integer" value="#{personHome.id}" />
+ <navigation from-action="#{personHome.update}">
+ <rule if-outcome="updated">
+ <render/>
+ </rule>
+ </navigation>
</page>
<page view-id="/formattedText.xhtml">
@@ -20,6 +25,11 @@
<page view-id="/fileUpload.xhtml">
<begin-conversation join="true"/>
<param name="personId" converterId="javax.faces.Integer" value="#{personHome.id}" />
+ <navigation from-action="#{personHome.update}">
+ <rule if-outcome="updated">
+ <render/>
+ </rule>
+ </navigation>
</page>
<page view-id="/graphicImage.xhtml">
14 years, 9 months
Seam SVN: r12038 - in branches/enterprise/JBPAPP_5_0/examples/restbay: resources/WEB-INF and 3 other directories.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2010-02-11 08:28:14 -0500 (Thu, 11 Feb 2010)
New Revision: 12038
Modified:
branches/enterprise/JBPAPP_5_0/examples/restbay/resources/WEB-INF/components.xml
branches/enterprise/JBPAPP_5_0/examples/restbay/resources/log4j.xml
branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/SecuredResource.java
branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/eventcomponent/EventComponentTestResource.java
branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/test/BasicServiceTest.java
branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/test/SecurityTest.java
Log:
JBPAPP-3713 tests
Modified: branches/enterprise/JBPAPP_5_0/examples/restbay/resources/WEB-INF/components.xml
===================================================================
--- branches/enterprise/JBPAPP_5_0/examples/restbay/resources/WEB-INF/components.xml 2010-02-11 12:58:29 UTC (rev 12037)
+++ branches/enterprise/JBPAPP_5_0/examples/restbay/resources/WEB-INF/components.xml 2010-02-11 13:28:14 UTC (rev 12038)
@@ -8,6 +8,7 @@
xmlns:web="http://jboss.com/products/seam/web"
xmlns:resteasy="http://jboss.com/products/seam/resteasy"
xmlns:framework="http://jboss.com/products/seam/framework"
+ xmlns:transaction="http://jboss.com/products/seam/transaction"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.2.xsd
@@ -18,6 +19,7 @@
http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.2.xsd
http://jboss.com/products/seam/resteasy http://jboss.com/products/seam/resteasy-2.2.xsd
http://jboss.com/products/seam/framework http://jboss.com/products/seam/framework-2.2.xsd
+ http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.2.xsd
http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.2.xsd">
<core:init jndi-pattern="@jndiPattern@" debug="true"/>
@@ -25,6 +27,8 @@
<core:manager conversation-timeout="120000"
concurrent-request-timeout="500"
conversation-id-parameter="cid"/>
+
+ <transaction:ejb-transaction />
<persistence:managed-persistence-context name="entityManager" auto-create="true"
persistence-unit-jndi-name="java:/restbayEntityManagerFactory"/>
Modified: branches/enterprise/JBPAPP_5_0/examples/restbay/resources/log4j.xml
===================================================================
--- branches/enterprise/JBPAPP_5_0/examples/restbay/resources/log4j.xml 2010-02-11 12:58:29 UTC (rev 12037)
+++ branches/enterprise/JBPAPP_5_0/examples/restbay/resources/log4j.xml 2010-02-11 13:28:14 UTC (rev 12038)
@@ -54,7 +54,7 @@
<!-- ############### Seam logging ################### -->
<category name="org.jboss.seam">
- <priority value="ERROR"/>
+ <priority value="WARN"/>
</category>
<category name="org.jboss.seam.resteasy">
@@ -63,7 +63,7 @@
<!-- Seam logs exceptions as WARN and re-throws them, switch to ERROR level -->
<category name="org.jboss.seam.web.ExceptionFilter">
- <priority value="ERROR"/>
+ <priority value="INFO"/>
</category>
<!-- These things are too noisy
Modified: branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/SecuredResource.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/SecuredResource.java 2010-02-11 12:58:29 UTC (rev 12037)
+++ branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/SecuredResource.java 2010-02-11 13:28:14 UTC (rev 12038)
@@ -4,10 +4,13 @@
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
+import org.jboss.seam.Component;
+import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.security.Identity;
+import org.jboss.seam.transaction.Synchronizations;
/**
*
@@ -43,4 +46,20 @@
return identity.hasRole("admin");
}
+ @GET
+ @Path("/synchronizationsLookup")
+ public boolean synchronizationsLookup()
+ {
+ Synchronizations ejb = (Synchronizations) Component.getInstance("org.jboss.seam.transaction.synchronizations", ScopeType.EVENT);
+ return ejb.isAwareOfContainerTransactions();
+ }
+
+ @GET
+ @Path("/ejbLookup")
+ public boolean ejbLookup()
+ {
+ TestEjbLocal ejb = (TestEjbLocal) Component.getInstance("securedEjb", ScopeType.EVENT);
+ return ejb.foo();
+ }
+
}
Modified: branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/eventcomponent/EventComponentTestResource.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/eventcomponent/EventComponentTestResource.java 2010-02-11 12:58:29 UTC (rev 12037)
+++ branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/eventcomponent/EventComponentTestResource.java 2010-02-11 13:28:14 UTC (rev 12038)
@@ -1,12 +1,15 @@
package org.jboss.seam.example.restbay.resteasy.eventcomponent;
import org.jboss.resteasy.annotations.Form;
+import org.jboss.seam.Component;
+import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.In;
import org.jboss.seam.example.restbay.resteasy.TestResource;
import org.jboss.seam.example.restbay.resteasy.TestComponent;
import org.jboss.seam.example.restbay.resteasy.TestForm;
import org.jboss.seam.example.restbay.resteasy.SubResource;
+import org.jboss.seam.transaction.Synchronizations;
import javax.ws.rs.Consumes;
import javax.ws.rs.CookieParam;
@@ -156,4 +159,12 @@
{
return super.getCommaSeparatedIntegers();
}
+
+ @GET
+ @Path("/synchronizationsLookup")
+ public boolean synchronizationsLookup()
+ {
+ Synchronizations ejb = (Synchronizations) Component.getInstance("org.jboss.seam.transaction.synchronizations", ScopeType.EVENT);
+ return ejb.isAwareOfContainerTransactions();
+ }
}
Modified: branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/test/BasicServiceTest.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/test/BasicServiceTest.java 2010-02-11 12:58:29 UTC (rev 12037)
+++ branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/test/BasicServiceTest.java 2010-02-11 13:28:14 UTC (rev 12038)
@@ -404,4 +404,26 @@
// TODO: Retracted support for Seam component providers, injection shouldn't happen, see https://jira.jboss.org/jira/browse/JBSEAM-4247
}
+
+ @Test
+ // JBPAPP-3713
+ public void synchronizationsLookup() throws Exception
+ {
+ new ResourceRequest(requestEnv, Method.GET, "/restv1/eventComponentTest/synchronizationsLookup")
+ {
+ @Override
+ protected void prepareRequest(EnhancedMockHttpServletRequest request)
+ {
+ super.prepareRequest(request);
+ }
+
+ @Override
+ protected void onResponse(EnhancedMockHttpServletResponse response)
+ {
+ assertEquals(response.getStatus(), 200, "Unexpected response code.");
+ assert response.getContentAsString().equals("true");
+ }
+
+ }.run();
+ }
}
Modified: branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/test/SecurityTest.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/test/SecurityTest.java 2010-02-11 12:58:29 UTC (rev 12037)
+++ branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/test/SecurityTest.java 2010-02-11 13:28:14 UTC (rev 12038)
@@ -159,5 +159,52 @@
}.run();
}
-
+
+ @Test
+ // JBPAPP-3713
+ public void ejbLookup() throws Exception
+ {
+ new ResourceRequest(requestEnv, Method.GET, "/restv1/secured/ejbLookup")
+ {
+ @Override
+ protected void prepareRequest(EnhancedMockHttpServletRequest request)
+ {
+ super.prepareRequest(request);
+ request.addHeader("Accept", "text/plain");
+ request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
+ }
+
+ @Override
+ protected void onResponse(EnhancedMockHttpServletResponse response)
+ {
+ assertEquals(response.getStatus(), 200, "Unexpected response code.");
+ assert response.getContentAsString().equals("true");
+ }
+
+ }.run();
+ }
+
+ @Test
+ // JBPAPP-3713
+ public void synchronizationsLookup() throws Exception
+ {
+ new ResourceRequest(requestEnv, Method.GET, "/restv1/secured/synchronizationsLookup")
+ {
+ @Override
+ protected void prepareRequest(EnhancedMockHttpServletRequest request)
+ {
+ super.prepareRequest(request);
+ request.addHeader("Accept", "text/plain");
+ request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
+ }
+
+ @Override
+ protected void onResponse(EnhancedMockHttpServletResponse response)
+ {
+ assertEquals(response.getStatus(), 200, "Unexpected response code.");
+ assert response.getContentAsString().equals("true");
+ }
+
+ }.run();
+ }
}
14 years, 9 months
Seam SVN: r12037 - branches/community/Seam_2_2/examples/seambay/resources/WEB-INF.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2010-02-11 07:58:29 -0500 (Thu, 11 Feb 2010)
New Revision: 12037
Modified:
branches/community/Seam_2_2/examples/seambay/resources/WEB-INF/pages.xml
Log:
JBSEAM-4533 Seambay example
Modified: branches/community/Seam_2_2/examples/seambay/resources/WEB-INF/pages.xml
===================================================================
--- branches/community/Seam_2_2/examples/seambay/resources/WEB-INF/pages.xml 2010-02-11 12:03:32 UTC (rev 12036)
+++ branches/community/Seam_2_2/examples/seambay/resources/WEB-INF/pages.xml 2010-02-11 12:58:29 UTC (rev 12037)
@@ -43,6 +43,9 @@
<param name="id" value="#{bidAction.bid.auction.auctionId}"/>
</redirect>
</rule>
+ <rule if-outcome="outbid">
+ <render/>
+ </rule>
</navigation>
</page>
14 years, 9 months
Seam SVN: r12036 - branches/community/Seam_2_2/src/test/ftest/examples/seambay/src/org/jboss/seam/example/seambay/test/selenium.
by seam-commits@lists.jboss.org
Author: mgencur(a)redhat.com
Date: 2010-02-11 07:03:32 -0500 (Thu, 11 Feb 2010)
New Revision: 12036
Modified:
branches/community/Seam_2_2/src/test/ftest/examples/seambay/src/org/jboss/seam/example/seambay/test/selenium/BidTest.java
branches/community/Seam_2_2/src/test/ftest/examples/seambay/src/org/jboss/seam/example/seambay/test/selenium/seambay.properties
Log:
fixed test so that it works with both jboss5 and jboss6
Modified: branches/community/Seam_2_2/src/test/ftest/examples/seambay/src/org/jboss/seam/example/seambay/test/selenium/BidTest.java
===================================================================
--- branches/community/Seam_2_2/src/test/ftest/examples/seambay/src/org/jboss/seam/example/seambay/test/selenium/BidTest.java 2010-02-11 09:29:56 UTC (rev 12035)
+++ branches/community/Seam_2_2/src/test/ftest/examples/seambay/src/org/jboss/seam/example/seambay/test/selenium/BidTest.java 2010-02-11 12:03:32 UTC (rev 12036)
@@ -47,7 +47,14 @@
search(title);
browser.clickAndWait(getProperty("SEARCH_RESULTS_FIRST_ROW_LINK"));
browser.clickAndWait(getProperty("ITEM_BID_HISTORY"));
- bidCount = browser.getXpathCount(getProperty("BID_HISTORY_COUNT")).intValue();
+ if (browser.isElementPresent(getProperty("BID_HISTORY_COUNT_EMPTY")))
+ {
+ bidCount = 0;
+ }
+ else
+ {
+ bidCount = browser.getXpathCount(getProperty("BID_HISTORY_COUNT")).intValue();
+ }
browser.goBackAndWait();
placeBid(price);
assertTrue("Auction page expected.", browser.getLocation().contains(getProperty("AUCTION_URL")));
Modified: branches/community/Seam_2_2/src/test/ftest/examples/seambay/src/org/jboss/seam/example/seambay/test/selenium/seambay.properties
===================================================================
--- branches/community/Seam_2_2/src/test/ftest/examples/seambay/src/org/jboss/seam/example/seambay/test/selenium/seambay.properties 2010-02-11 09:29:56 UTC (rev 12035)
+++ branches/community/Seam_2_2/src/test/ftest/examples/seambay/src/org/jboss/seam/example/seambay/test/selenium/seambay.properties 2010-02-11 12:03:32 UTC (rev 12036)
@@ -51,6 +51,7 @@
BID_CONFIRM id=confirm:confirmBid
BID_HISTORY_COUNT //table[@id='history']/tbody/tr
+BID_HISTORY_COUNT_EMPTY //table[@id='history']/tbody/tr/td[not(text())]
BID_OUTBID id=outbid
BID_HIGH_BIDDER id\=highBidder
BID_HISTORY_BACK id\=back
14 years, 9 months
Seam SVN: r12035 - modules/remoting/trunk/docs/en-US/images.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-02-11 04:29:56 -0500 (Thu, 11 Feb 2010)
New Revision: 12035
Added:
modules/remoting/trunk/docs/en-US/images/remoting-model-customer-address-uml.png
Log:
added missing image
Added: modules/remoting/trunk/docs/en-US/images/remoting-model-customer-address-uml.png
===================================================================
(Binary files differ)
Property changes on: modules/remoting/trunk/docs/en-US/images/remoting-model-customer-address-uml.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
14 years, 9 months
Seam SVN: r12034 - modules/remoting/trunk/docs/en-US.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-02-11 04:29:11 -0500 (Thu, 11 Feb 2010)
New Revision: 12034
Modified:
modules/remoting/trunk/docs/en-US/remoting-model.xml
Log:
more model api docs
Modified: modules/remoting/trunk/docs/en-US/remoting-model.xml
===================================================================
--- modules/remoting/trunk/docs/en-US/remoting-model.xml 2010-02-11 04:10:27 UTC (rev 12033)
+++ modules/remoting/trunk/docs/en-US/remoting-model.xml 2010-02-11 09:29:11 UTC (rev 12034)
@@ -52,7 +52,7 @@
<literal>Seam.Action</literal> takes no parameters:
</para>
- <programlisting><![CDATA[ var action = new Seam.Action();]]></programlisting>
+ <programlisting role="XHTML"><![CDATA[ var action = new Seam.Action();]]></programlisting>
<para>
The following table lists the methods used to define the action. Each of the following methods
@@ -165,7 +165,7 @@
the Model API in JavaScript you must first create a new Model object:
</para>
- <programlisting><![CDATA[ var model = new Seam.Model();]]></programlisting>
+ <programlisting role="XHTML"><![CDATA[ var model = new Seam.Model();]]></programlisting>
<table>
<title>Seam.Model method reference</title>
@@ -235,6 +235,12 @@
Can only be used before the model is fetched.
</para>
+ <para>
+ Example:
+ </para>
+
+ <programlisting role="XHTML"><![CDATA[ addBeanProperty("account", "AccountAction", "account", "@Qualifier1", "@Qualifier2");]]></programlisting>
+
<itemizedlist>
<listitem>
<literal>alias</literal> - the local alias for the bean value.
@@ -247,7 +253,8 @@
<literal>property</literal> - the name of the bean property.
</listitem>
<listitem>
- <literal>qualifiers</literal> (optional) - a list of bean qualifiers.
+ <literal>qualifiers</literal> (optional) - a list of bean qualifiers. This parameter (and any
+ after it) are treated as bean qualifiers.
</listitem>
</itemizedlist>
</entry>
@@ -382,44 +389,32 @@
<para>
To fetch a model, one or more values must first be specified using <literal>addBean()</literal> or
<literal>addBeanProperty()</literal> before invoking the <literal>fetch()</literal> operation.
- Let's work through an example - here we have an entity bean called <literal>Customer</literal>
- and a bean called <literal>CustomerAction</literal>. The <literal>CustomerAction</literal> bean
- is used to create and edit <literal>Customer</literal> instances. Since we're only interested in
- editing a customer right now, the following code only shows the <literal>editCustomer()</literal>
- method:
+ Let's work through an example - here we have an entity bean called <literal>Customer</literal>:
</para>
-
- <programlisting><![CDATA[@Entity Customer implements Serializable {
+
+ <programlisting role="JAVA"><![CDATA[@Entity Customer implements Serializable {
private Integer customerId;
private String firstName;
private String lastName;
- @Id @GeneratedValue public Integer getCustomerId() {
- return customerId;
- }
+ @Id @GeneratedValue public Integer getCustomerId() { return customerId; }
+ public void setCustomerId(Integer customerId) { this.customerId = customerId; }
- public void setCustomerId(Integer customerId) {
- this.customerId = customerId;
- }
+ public String getFirstName() { return firstName; }
+ public void setFirstName(String firstName) { this.firstName = firstName; }
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
+ public String getLastName() { return lastName; }
+ public void setLastName(String lastName) { this.lastName = lastName; }
}]]></programlisting>
+
+ <para>
+ We also have a bean called <literal>CustomerAction</literal>, which is responsible for creating and editing
+ <literal>Customer</literal> instances. Since we're only interested in editing a customer right now, the
+ following code only shows the <literal>editCustomer()</literal> method:
+ </para>
+
- <programlisting><![CDATA[@ConversationScoped @Named
+ <programlisting role="JAVA"><![CDATA[@ConversationScoped @Named
public class CustomerAction {
@Inject Conversation conversation;
@PersistenceContext EntityManager entityManager;
@@ -445,15 +440,15 @@
by using the <literal>addBeanProperty()</literal> method to add a bean property to the model:
</para>
- <programlisting><![CDATA[ var model = new Seam.Model();
+ <programlisting role="XHTML"><![CDATA[ var model = new Seam.Model();
model.addBeanProperty("customer", "CustomerAction", "customer");]]></programlisting>
<para>
The first parameter of <literal>addBeanProperty()</literal> is the <emphasis>alias</emphasis> (in this case
<literal>customer</literal>), which is used to access the value via the <literal>getValue()</literal> method.
The <literal>addBeanProperty()</literal> and <literal>addBean()</literal> methods can be called multiple times
- to bind multiple values to the model. An important thing to note is that the values can come from multiple
- server-side beans, they don't all need to come from the same bean.
+ to bind multiple values to the model. An important thing to note is that the values may come from multiple
+ server-side beans, they aren't all required to come from the same bean.
</para>
<mediaobject>
@@ -468,7 +463,7 @@
specify this value as an action method parameter:
</para>
- <programlisting><![CDATA[ var action = new Seam.Action()
+ <programlisting role="XHTML"><![CDATA[ var action = new Seam.Action()
.setBeanType("CustomerAction")
.setMethod("editCustomer")
.addParam(123);]]></programlisting>
@@ -480,7 +475,7 @@
response. The callback method is passed a reference to the model object as a parameter.
</para>
- <programlisting><![CDATA[ var callback = function(model) { alert("Fetched customer: " model.getValue("customer").firstName +
+ <programlisting role="XHTML"><![CDATA[ var callback = function(model) { alert("Fetched customer: " model.getValue("customer").firstName +
" " + model.getValue("customer").lastName); };
model.fetch(action, callback);]]></programlisting>
@@ -488,12 +483,130 @@
When the server receives a model fetch request, it first invokes the action (if one is specified) before
reading the requested property values and returning them to the client.
</para>
+
+ <section>
+ <title>Fetching a bean value</title>
+
+ <para>
+ Alternatively, if you don't wish to fetch a bean <emphasis>property</emphasis> but rather a bean itself
+ (such as a value created by a producer method) then the <literal>addBean()</literal> method is used instead.
+ Let's say we have a producer method that returns a qualified <literal>UserSettings</literal> value:
+ </para>
+
+ <programlisting role="JAVA"><![CDATA[ @Produces @ConversationScoped @Settings UserSettings getUserSettings() {
+ /* snip code */
+ }]]></programlisting>
+
+ <para>
+ We would add this value to our model with the following code:
+ </para>
+
+ <programlisting role="XHTML"><![CDATA[ model.addBean("settings", "UserSettings", "@Settings");]]></programlisting>
+
+ <para>
+ The first parameter is the local alias for the value, the second parameter is the fully qualified
+ class of the bean, and the third (and subsequent) parameter/s are optional bean qualifiers.
+ </para>
+
+ </section>
</section>
<section>
+ <title>Modifying model values</title>
+
+ <para>
+ Once a model has been fetched its values may be read using the <literal>getValue()</literal> method.
+ Continuing on with the previous example, we would retrieve the <literal>Customer</literal> object via
+ it's local alias (<literal>customer</literal>) like this:
+ </para>
+
+ <programlisting role="XHTML"><![CDATA[ var customer = model.getValue("customer");]]></programlisting>
+
+ <para>
+ We are then free to read or modify the properties of the value (or any of the other values within its
+ object graph).
+ </para>
+
+ <programlisting role="XHTML"><![CDATA[ alert("Customer name is: " + customer.firstName + " " + customer.lastName);
+ customer.setLastName("Jones"); // was Smith, but Peggy got married on the weekend]]></programlisting>
+
+ </section>
+
+ <section>
<title>Expanding a model</title>
+ <para>
+ We can use the Model API's ability to expand a model to load uninitialized branches of the objects in
+ the model's object graph. To understand how this works exactly, let's flesh out our example a little
+ more by adding an <literal>Address</literal> entity class, and creating a one-to-many relationship
+ between <literal>Customer</literal> and <literal>Address</literal>.
+ </para>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/remoting-model-customer-address-uml.png" format="PNG"/>
+ </imageobject>
+ </mediaobject>
+
+ <programlisting role="JAVA"><![CDATA[@Entity Address implements Serializable {
+ private Integer addressId;
+ private Customer customer;
+ private String unitNumber;
+ private String streetNumber;
+ private String streetName;
+ private String suburb;
+ private String zip;
+ private String state;
+ private String country;
+
+ @Id @GeneratedValue public Integer getAddressId() { return addressId; }
+ public void setAddressId(Integer addressId) { this.addressId = addressId; }
+
+ @ManyToOne public Customer getCustomer() { return customer; }
+ public void setCustomer(Customer customer) { this.customer = customer; }
+
+ /* Snipped other getter/setter methods */
+
+}]]></programlisting>
+
+ <para>
+ Here's the new field and methods that we also need to add to the <literal>Customer</literal> class:
+ </para>
+
+ <programlisting role="JAVA"><![CDATA[ private Collection<Address> addresses;
+
+ @OneToMany(fetch = FetchType.LAZY, mappedBy = "customer", cascade = CascadeType.ALL)
+ public Collection<Address> getAddresses() { return addresses; }
+ public void setAddresses(Collection<Address> addresses) { this.addresses = addresses; }]]></programlisting>
+
+ <para>
+ As we can see, the <literal>@OneToMany</literal> annotation on the <literal>getAddresses()</literal>
+ method specifies a <literal>fetch</literal> attribute of <literal>LAZY</literal>, meaning that by
+ default the customer's addresses won't be loaded automatically when the customer is. When reading the
+ <emphasis>uninitialized</emphasis> <literal>addresses</literal> property value from a newly-fetched
+ <literal>Customer</literal> object in JavaScript, a value of <literal>undefined</literal> will be returned.
+ </para>
+
+ <programlisting role="XHTML"><![CDATA[ getValue("customer").addresses == undefined; // returns true]]></programlisting>
+
+ <para>
+ We can <emphasis>expand</emphasis> the model by making a special request to initialize this uninitialized
+ property value. The <literal>expand()</literal> operation takes three parameters - the value containing
+ the property to be initialized, the name of the property and an optional callback method. The following
+ example shows us how the customer's <literal>addresses</literal> property can be initialized:
+ </para>
+
+ <programlisting role="XHTML"><![CDATA[ model.expand(model.getValue("customer"), "addresses");]]></programlisting>
+
+ <para>
+ The <literal>expand()</literal> operation makes an asynchronous request to the server, where the
+ property value is initialized and the value returned to the client. When the client receives the
+ response, it reads the initialized value and appends it to the model.
+ </para>
+
+ <programlisting role="XHTML"><![CDATA[ // The addresses property now contains an array of address objects
+ alert(model.getValue("customer").addresses.length + " addresses loaded");]]></programlisting>
+
</section>
<section>
14 years, 9 months
Seam SVN: r12033 - modules/remoting/trunk/docs/en-US.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-02-10 23:10:27 -0500 (Wed, 10 Feb 2010)
New Revision: 12033
Modified:
modules/remoting/trunk/docs/en-US/remoting-model.xml
Log:
more model api docs
Modified: modules/remoting/trunk/docs/en-US/remoting-model.xml
===================================================================
--- modules/remoting/trunk/docs/en-US/remoting-model.xml 2010-02-11 00:42:25 UTC (rev 12032)
+++ modules/remoting/trunk/docs/en-US/remoting-model.xml 2010-02-11 04:10:27 UTC (rev 12033)
@@ -55,7 +55,8 @@
<programlisting><![CDATA[ var action = new Seam.Action();]]></programlisting>
<para>
- The following table lists the methods used to define the action.
+ The following table lists the methods used to define the action. Each of the following methods
+ return a reference to the <literal>Seam.Action</literal> object, so methods can be chained.
</para>
<table>
@@ -381,15 +382,13 @@
<para>
To fetch a model, one or more values must first be specified using <literal>addBean()</literal> or
<literal>addBeanProperty()</literal> before invoking the <literal>fetch()</literal> operation.
- Let's work through an example
+ Let's work through an example - here we have an entity bean called <literal>Customer</literal>
+ and a bean called <literal>CustomerAction</literal>. The <literal>CustomerAction</literal> bean
+ is used to create and edit <literal>Customer</literal> instances. Since we're only interested in
+ editing a customer right now, the following code only shows the <literal>editCustomer()</literal>
+ method:
</para>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/remoting-model-customer-uml-1.png" format="PNG"/>
- </imageobject>
- </mediaobject>
-
<programlisting><![CDATA[@Entity Customer implements Serializable {
private Integer customerId;
private String firstName;
@@ -426,11 +425,69 @@
@PersistenceContext EntityManager entityManager;
public Customer customer;
- public void createCustomer() {
- customer = new Customer();
- conversation.begin();
+ public void editCustomer(Integer customerId) {
+ conversation.begin();
+ customer = entityManager.find(Customer.class, customerId);
}
+
+ public void saveCustomer() {
+ entityManager.merge(customer);
+ conversation.end();
+ }
}]]></programlisting>
+
+ <para>
+ In the client section of this example, we wish to make changes to an existing <literal>Customer</literal>
+ instance, so we need to use the <literal>editCustomer()</literal> method of <literal>CustomerAction</literal>
+ to first load the customer entity, after which we can access it via the public <literal>customer</literal>
+ field. Our model object must therefore be configured to fetch the <literal>CustomerAction.customer</literal>
+ property, and to invoke the <literal>editCustomer()</literal> method when the model is fetched. We start
+ by using the <literal>addBeanProperty()</literal> method to add a bean property to the model:
+ </para>
+
+ <programlisting><![CDATA[ var model = new Seam.Model();
+ model.addBeanProperty("customer", "CustomerAction", "customer");]]></programlisting>
+
+ <para>
+ The first parameter of <literal>addBeanProperty()</literal> is the <emphasis>alias</emphasis> (in this case
+ <literal>customer</literal>), which is used to access the value via the <literal>getValue()</literal> method.
+ The <literal>addBeanProperty()</literal> and <literal>addBean()</literal> methods can be called multiple times
+ to bind multiple values to the model. An important thing to note is that the values can come from multiple
+ server-side beans, they don't all need to come from the same bean.
+ </para>
+
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/remoting-model-customer-uml-1.png" format="PNG"/>
+ </imageobject>
+ </mediaobject>
+
+ <para>
+ We also specify the action that we wish to invoke (i.e. the <literal>editCustomer()</literal> method).
+ In this example we know the value of the <literal>customerId</literal> that we wish to edit, so we can
+ specify this value as an action method parameter:
+ </para>
+
+ <programlisting><![CDATA[ var action = new Seam.Action()
+ .setBeanType("CustomerAction")
+ .setMethod("editCustomer")
+ .addParam(123);]]></programlisting>
+
+ <para>
+ Once we've specified the bean properties we wish to fetch and the action to invoke, we can then fetch the
+ model. We pass in a reference to the action object as the first parameter of the <literal>fetch()</literal>
+ method. Also, since this is an asynchronous request we need to provide a callback method to deal with the
+ response. The callback method is passed a reference to the model object as a parameter.
+ </para>
+
+ <programlisting><![CDATA[ var callback = function(model) { alert("Fetched customer: " model.getValue("customer").firstName +
+ " " + model.getValue("customer").lastName); };
+ model.fetch(action, callback);]]></programlisting>
+
+ <para>
+ When the server receives a model fetch request, it first invokes the action (if one is specified) before
+ reading the requested property values and returning them to the client.
+ </para>
</section>
<section>
14 years, 9 months
Seam SVN: r12032 - branches/community/Seam_2_2/src/main/org/jboss/seam/security/jaas.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-02-10 19:42:25 -0500 (Wed, 10 Feb 2010)
New Revision: 12032
Modified:
branches/community/Seam_2_2/src/main/org/jboss/seam/security/jaas/SeamLoginModule.java
Log:
JBSEAM-2164
Modified: branches/community/Seam_2_2/src/main/org/jboss/seam/security/jaas/SeamLoginModule.java
===================================================================
--- branches/community/Seam_2_2/src/main/org/jboss/seam/security/jaas/SeamLoginModule.java 2010-02-11 00:17:27 UTC (rev 12031)
+++ branches/community/Seam_2_2/src/main/org/jboss/seam/security/jaas/SeamLoginModule.java 2010-02-11 00:42:25 UTC (rev 12032)
@@ -94,7 +94,7 @@
}
catch (Exception ex)
{
- log.warn("Error logging in");
+ log.warn("Error logging in", ex);
LoginException le = new LoginException(ex.getMessage());
le.initCause(ex);
throw le;
@@ -110,8 +110,10 @@
}
catch (Exception ex)
{
- log.warn("Error invoking login method", ex);
- throw new LoginException(ex.getMessage());
+ log.warn("Error invoking login method", ex);
+ LoginException le = new LoginException(ex.getMessage());
+ le.initCause(ex);
+ throw le;
}
}
14 years, 9 months