You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@apache.org on 2006/01/04 04:21:28 UTC
svn commit: r365809 - in /struts/shale/trunk/use-cases/src:
java/org/apache/shale/usecases/remoting/
java/org/apache/shale/usecases/remoting/Business.java
java/org/apache/shale/usecases/view/Bundle.properties
web/WEB-INF/faces-config.xml web/usecases.jsp
Author: craigmcc
Date: Tue Jan 3 19:21:24 2006
New Revision: 365809
URL: http://svn.apache.org/viewcvs?rev=365809&view=rev
Log:
Add examples using the new-style remoting APIs to use method bindings to
call business logic methods.
Added:
struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/remoting/
struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/remoting/Business.java (with props)
Modified:
struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/view/Bundle.properties
struts/shale/trunk/use-cases/src/web/WEB-INF/faces-config.xml
struts/shale/trunk/use-cases/src/web/usecases.jsp
Added: struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/remoting/Business.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/remoting/Business.java?rev=365809&view=auto
==============================================================================
--- struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/remoting/Business.java (added)
+++ struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/remoting/Business.java Tue Jan 3 19:21:24 2006
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shale.usecases.remoting;
+
+import java.io.IOException;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.model.SelectItem;
+import org.apache.shale.remoting.faces.ResponseFactory;
+import org.apache.shale.usecases.view.Domains;
+import org.apache.shale.view.AbstractFacesBean;
+
+/**
+ * <p>Remotely executable business logic methods that complete the entire
+ * response.</p>
+ *
+ * $Id$
+ */
+public class Business extends AbstractFacesBean {
+
+
+ // ---------------------------------------------------------- Public Methods
+
+
+ /**
+ * <p>Return the set of reported categories.</p>
+ */
+ public void listCategories() throws IOException {
+
+ FacesContext context = FacesContext.getCurrentInstance();
+ selectItems(context, supportedCategories(context));
+
+ }
+
+
+ /**
+ * <p>Return the set of reported locales.</p>
+ */
+ public void listLocales() throws IOException {
+
+ FacesContext context = FacesContext.getCurrentInstance();
+ selectItems(context, supportedLocales(context));
+
+ }
+
+
+
+ // ------------------------------------------------------- Protected Methods
+
+
+ /**
+ * <p>Render an XML document containing the specified selection items
+ * as the response to this request.</p>
+ *
+ * @param context <code>FacesContext</code> for the current request
+ * @param items Selection items to be rendered
+ */
+ protected void selectItems(FacesContext context, SelectItem items[]) throws IOException {
+
+ ResponseWriter writer =
+ (new ResponseFactory()).getResponseWriter(context, "text/xml");
+
+ // Generate the response content
+ writer.startDocument();
+ writer.startElement("items", null);
+ writer.write("\n");
+ for (int i = 0; i < items.length; i++) {
+ writer.startElement("item", null);
+ writer.write("\n");
+ Object value = items[i].getValue();
+ if (value != null) {
+ writer.startElement("value", null);
+ writer.writeText(value, null);
+ writer.endElement("value");
+ writer.write("\n");
+ }
+ String label = items[i].getLabel();
+ if (label != null) {
+ writer.startElement("label", null);
+ writer.writeText(label, null);
+ writer.endElement("label");
+ writer.write("\n");
+ }
+ String description = items[i].getLabel();
+ if (description != null) {
+ writer.startElement("description", null);
+ writer.writeText(description, null);
+ writer.endElement("description");
+ writer.write("\n");
+ }
+ writer.endElement("item");
+ writer.write("\n");
+ }
+ writer.endElement("items");
+ writer.write("\n");
+
+ context.responseComplete();
+
+ }
+
+
+ /**
+ * <p>Return the set of legal supported categories.</p>
+ *
+ * @param context <code>FacesContext</code> for the current request
+ */
+ protected SelectItem[] supportedCategories(FacesContext context) {
+
+ Domains domains = (Domains) getBean("domains");
+ return domains.getSupportedCategories(context.getViewRoot().getLocale());
+
+ }
+
+
+ /**
+ * <p>Return the set of legal supported locales.</p>
+ *
+ * @param context <code>FacesContext</code> for the current request
+ */
+ protected SelectItem[] supportedLocales(FacesContext context) {
+
+ Domains domains = (Domains) getBean("domains");
+ return domains.getSupportedLocales(context.getViewRoot().getLocale());
+
+ }
+
+
+}
Propchange: struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/remoting/Business.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/remoting/Business.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/view/Bundle.properties
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/view/Bundle.properties?rev=365809&r1=365808&r2=365809&view=diff
==============================================================================
--- struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/view/Bundle.properties (original)
+++ struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/view/Bundle.properties Tue Jan 3 19:21:24 2006
@@ -109,14 +109,15 @@
usecases.ajax=Ajax Interactions
usecases.completion=Code Completion (Standard JSF Components)
usecases.edit=Edit User Profile
-usecases.java=Remoting Support (Java Based)
+usecases.java=Old-Style Remoting Support (Java Based)
usecases.jndi=JNDI Access Via Expressions
-usecases.jsp=Remoting Support (JSP Based)
+usecases.jsp=Old-Style Remoting Support (JSP Based)
usecases.locale=Select Language
usecases.locales=List Locales (Remoting)
usecases.logoff=Log Off
usecases.logon=Log On Dialog
usecases.primary=Primary Use Cases
+usecases.remoting=New Style Remoting Support
usecases.states=List State Names (Remoting)
usecases.subview=Subview Processing
usecases.title=Shale Framework Use Cases
Modified: struts/shale/trunk/use-cases/src/web/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/use-cases/src/web/WEB-INF/faces-config.xml?rev=365809&r1=365808&r2=365809&view=diff
==============================================================================
--- struts/shale/trunk/use-cases/src/web/WEB-INF/faces-config.xml (original)
+++ struts/shale/trunk/use-cases/src/web/WEB-INF/faces-config.xml Tue Jan 3 19:21:24 2006
@@ -232,13 +232,13 @@
<from-action>#{rolodex.changeTab}</from-action>
<from-outcome>rolodex$test</from-outcome>
<to-view-id>/rolodex/rolodex.jsp</to-view-id>
- </navigation-case>
- <navigation-case>
- <from-action>home</from-action>
- <from-outcome>home</from-outcome>
- <to-view-id>/usecases.faces</to-view-id>
- <redirect/>
- </navigation-case>
+ </navigation-case>
+ <navigation-case>
+ <from-action>home</from-action>
+ <from-outcome>home</from-outcome>
+ <to-view-id>/usecases.faces</to-view-id>
+ <redirect/>
+ </navigation-case>
</navigation-rule>
@@ -271,13 +271,13 @@
<from-action>#{rolodex$hrolodex.changeTab}</from-action>
<from-outcome>rolodex$test</from-outcome>
<to-view-id>/rolodex/hrolodex.html</to-view-id>
- </navigation-case>
- <navigation-case>
- <from-action>home</from-action>
- <from-outcome>home</from-outcome>
- <to-view-id>/usecases.faces</to-view-id>
- <redirect/>
- </navigation-case>
+ </navigation-case>
+ <navigation-case>
+ <from-action>home</from-action>
+ <from-outcome>home</from-outcome>
+ <to-view-id>/usecases.faces</to-view-id>
+ <redirect/>
+ </navigation-case>
</navigation-rule>
@@ -309,13 +309,13 @@
<from-action>#{rolodex$xhrolodex.changeTab}</from-action>
<from-outcome>rolodex$test</from-outcome>
<to-view-id>/rolodex/xhrolodex.html</to-view-id>
- </navigation-case>
- <navigation-case>
- <from-action>home</from-action>
- <from-outcome>home</from-outcome>
- <to-view-id>/usecases.faces</to-view-id>
- <redirect/>
- </navigation-case>
+ </navigation-case>
+ <navigation-case>
+ <from-action>home</from-action>
+ <from-outcome>home</from-outcome>
+ <to-view-id>/usecases.faces</to-view-id>
+ <redirect/>
+ </navigation-case>
</navigation-rule>
@@ -349,22 +349,22 @@
<from-outcome>rolodex$test</from-outcome>
<to-view-id>/rolodex/rolodex.xml</to-view-id>
</navigation-case>
- <navigation-case>
- <from-action>home</from-action>
- <from-outcome>home</from-outcome>
- <to-view-id>/usecases.faces</to-view-id>
- <redirect/>
- </navigation-case>
+ <navigation-case>
+ <from-action>home</from-action>
+ <from-outcome>home</from-outcome>
+ <to-view-id>/usecases.faces</to-view-id>
+ <redirect/>
+ </navigation-case>
</navigation-rule>
- <navigation-rule>
- <from-view-id>*</from-view-id>
- <navigation-case>
- <from-outcome>home</from-outcome>
- <to-view-id>/usecases.jsp</to-view-id>
- </navigation-case>
- </navigation-rule>
+ <navigation-rule>
+ <from-view-id>*</from-view-id>
+ <navigation-case>
+ <from-outcome>home</from-outcome>
+ <to-view-id>/usecases.jsp</to-view-id>
+ </navigation-case>
+ </navigation-rule>
<navigation-rule>
<navigation-case>
@@ -488,6 +488,22 @@
<to-view-id>/lookup/listLocales.jsp</to-view-id>
</navigation-case>
</navigation-rule>
+
+
+ <!-- ======================== Remoting Support =========================== -->
+
+
+ <managed-bean>
+ <description>
+ Business logic to produce lists of categories, locales, and state names
+ using the org.apache.shale.remoting package support.
+ </description>
+ <managed-bean-name>remoting$business</managed-bean-name>
+ <managed-bean-class>
+ org.apache.shale.usecases.remoting.Business
+ </managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
<!-- =========================== Subview Processing ====================== -->
Modified: struts/shale/trunk/use-cases/src/web/usecases.jsp
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/use-cases/src/web/usecases.jsp?rev=365809&r1=365808&r2=365809&view=diff
==============================================================================
--- struts/shale/trunk/use-cases/src/web/usecases.jsp (original)
+++ struts/shale/trunk/use-cases/src/web/usecases.jsp Tue Jan 3 19:21:24 2006
@@ -109,6 +109,24 @@
</h:panelGrid>
+ <h1><h:outputText value="#{messages['usecases.remoting']}"/></h1>
+
+ <h:panelGrid columns="1">
+
+ <h:outputLink id="remotingCategories"
+ value="dynamic/remoting$business/listCategories.faces"
+ target="_new">
+ <h:outputText value="#{messages['usecases.categories']}"/>
+ </h:outputLink>
+
+ <h:outputLink id="remotingLocales"
+ value="dynamic/remoting$business/listLocales.faces"
+ target="_new">
+ <h:outputText value="#{messages['usecases.locales']}"/>
+ </h:outputLink>
+
+ </h:panelGrid>
+
<h1><h:outputText value="#{messages['usecases.java']}"/></h1>
<h:panelGrid columns="1">
@@ -156,51 +174,51 @@
</h:panelGrid>
<h1><h:outputText value="#{messages['usecases.clay']}"/></h1>
- <h:panelGrid columns="2">
-
- <h:commandLink id="rolodex1"
- action="rolodex$test1" title="#{messages['usecases.rolodex1.title']}">
- <h:outputText value="#{messages['usecases.rolodex1']}"/>
-
- </h:commandLink>
- <h:commandLink action="rolodex$viewsource" title="#{messages['usecases.rolodex1.title']}">
- <f:param name="url" value="/rolodex/rolodex.jsp"/>
- <h:outputText value="#{messages['usecases.rolodex.viewsource']}"/>
- </h:commandLink>
-
-
- <h:commandLink id="rolodex2"
- action="rolodex$test2" title="#{messages['usecases.rolodex2.title']}">
- <h:outputText value="#{messages['usecases.rolodex2']}"/>
-
- </h:commandLink>
- <h:commandLink action="rolodex$viewsource" title="#{messages['usecases.rolodex2.title']}">
- <f:param name="url" value="/rolodex/hrolodex.html"/>
- <h:outputText value="#{messages['usecases.rolodex.viewsource']}"/>
- </h:commandLink>
-
- <h:commandLink id="rolodex3"
- action="rolodex$test3" title="#{messages['usecases.rolodex3.title']}">
- <h:outputText value="#{messages['usecases.rolodex3']}"/>
-
- </h:commandLink>
- <h:commandLink action="rolodex$viewsource" title="#{messages['usecases.rolodex3.title']}">
- <f:param name="url" value="/rolodex/xhrolodex.html"/>
- <h:outputText value="#{messages['usecases.rolodex.viewsource']}"/>
- </h:commandLink>
-
- <h:commandLink id="rolodex4"
- action="rolodex$test4" title="#{messages['usecases.rolodex4.title']}">
- <h:outputText value="#{messages['usecases.rolodex4']}"/>
-
- </h:commandLink>
- <h:commandLink action="rolodex$viewsource" title="#{messages['usecases.rolodex4.title']}">
- <f:param name="url" value="/rolodex/rolodex.xml"/>
- <h:outputText value="#{messages['usecases.rolodex.viewsource']}"/>
- </h:commandLink>
-
-
- </h:panelGrid>
+ <h:panelGrid columns="2">
+
+ <h:commandLink id="rolodex1"
+ action="rolodex$test1" title="#{messages['usecases.rolodex1.title']}">
+ <h:outputText value="#{messages['usecases.rolodex1']}"/>
+
+ </h:commandLink>
+ <h:commandLink action="rolodex$viewsource" title="#{messages['usecases.rolodex1.title']}">
+ <f:param name="url" value="/rolodex/rolodex.jsp"/>
+ <h:outputText value="#{messages['usecases.rolodex.viewsource']}"/>
+ </h:commandLink>
+
+
+ <h:commandLink id="rolodex2"
+ action="rolodex$test2" title="#{messages['usecases.rolodex2.title']}">
+ <h:outputText value="#{messages['usecases.rolodex2']}"/>
+
+ </h:commandLink>
+ <h:commandLink action="rolodex$viewsource" title="#{messages['usecases.rolodex2.title']}">
+ <f:param name="url" value="/rolodex/hrolodex.html"/>
+ <h:outputText value="#{messages['usecases.rolodex.viewsource']}"/>
+ </h:commandLink>
+
+ <h:commandLink id="rolodex3"
+ action="rolodex$test3" title="#{messages['usecases.rolodex3.title']}">
+ <h:outputText value="#{messages['usecases.rolodex3']}"/>
+
+ </h:commandLink>
+ <h:commandLink action="rolodex$viewsource" title="#{messages['usecases.rolodex3.title']}">
+ <f:param name="url" value="/rolodex/xhrolodex.html"/>
+ <h:outputText value="#{messages['usecases.rolodex.viewsource']}"/>
+ </h:commandLink>
+
+ <h:commandLink id="rolodex4"
+ action="rolodex$test4" title="#{messages['usecases.rolodex4.title']}">
+ <h:outputText value="#{messages['usecases.rolodex4']}"/>
+
+ </h:commandLink>
+ <h:commandLink action="rolodex$viewsource" title="#{messages['usecases.rolodex4.title']}">
+ <f:param name="url" value="/rolodex/rolodex.xml"/>
+ <h:outputText value="#{messages['usecases.rolodex.viewsource']}"/>
+ </h:commandLink>
+
+
+ </h:panelGrid>
</h:form>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org