Return-Path: Delivered-To: apmail-struts-dev-archive@www.apache.org Received: (qmail 55642 invoked from network); 4 Jan 2006 03:21:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Jan 2006 03:21:54 -0000 Received: (qmail 53231 invoked by uid 500); 4 Jan 2006 03:21:51 -0000 Delivered-To: apmail-struts-dev-archive@struts.apache.org Received: (qmail 53177 invoked by uid 500); 4 Jan 2006 03:21:51 -0000 Mailing-List: contact dev-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Developers List" Reply-To: "Struts Developers List" Delivered-To: mailing list dev@struts.apache.org Received: (qmail 53166 invoked by uid 500); 4 Jan 2006 03:21:51 -0000 Received: (qmail 53163 invoked by uid 99); 4 Jan 2006 03:21:51 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Jan 2006 19:21:51 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 03 Jan 2006 19:21:50 -0800 Received: (qmail 55556 invoked by uid 65534); 4 Jan 2006 03:21:29 -0000 Message-ID: <20060104032129.55555.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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 Date: Wed, 04 Jan 2006 03:21:28 -0000 To: commits@struts.apache.org From: craigmcc@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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; + +/** + *

Remotely executable business logic methods that complete the entire + * response.

+ * + * $Id$ + */ +public class Business extends AbstractFacesBean { + + + // ---------------------------------------------------------- Public Methods + + + /** + *

Return the set of reported categories.

+ */ + public void listCategories() throws IOException { + + FacesContext context = FacesContext.getCurrentInstance(); + selectItems(context, supportedCategories(context)); + + } + + + /** + *

Return the set of reported locales.

+ */ + public void listLocales() throws IOException { + + FacesContext context = FacesContext.getCurrentInstance(); + selectItems(context, supportedLocales(context)); + + } + + + + // ------------------------------------------------------- Protected Methods + + + /** + *

Render an XML document containing the specified selection items + * as the response to this request.

+ * + * @param context FacesContext 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(); + + } + + + /** + *

Return the set of legal supported categories.

+ * + * @param context FacesContext for the current request + */ + protected SelectItem[] supportedCategories(FacesContext context) { + + Domains domains = (Domains) getBean("domains"); + return domains.getSupportedCategories(context.getViewRoot().getLocale()); + + } + + + /** + *

Return the set of legal supported locales.

+ * + * @param context FacesContext 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 @@ #{rolodex.changeTab} rolodex$test /rolodex/rolodex.jsp - - - home - home - /usecases.faces - - + + + home + home + /usecases.faces + + @@ -271,13 +271,13 @@ #{rolodex$hrolodex.changeTab} rolodex$test /rolodex/hrolodex.html - - - home - home - /usecases.faces - - + + + home + home + /usecases.faces + + @@ -309,13 +309,13 @@ #{rolodex$xhrolodex.changeTab} rolodex$test /rolodex/xhrolodex.html - - - home - home - /usecases.faces - - + + + home + home + /usecases.faces + + @@ -349,22 +349,22 @@ rolodex$test /rolodex/rolodex.xml - - home - home - /usecases.faces - - + + home + home + /usecases.faces + + - - * - - home - /usecases.jsp - - + + * + + home + /usecases.jsp + + @@ -488,6 +488,22 @@ /lookup/listLocales.jsp + + + + + + + + Business logic to produce lists of categories, locales, and state names + using the org.apache.shale.remoting package support. + + remoting$business + + org.apache.shale.usecases.remoting.Business + + request + 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 @@ +

+ + + + + + + + + + + + +

@@ -156,51 +174,51 @@

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org For additional commands, e-mail: dev-help@struts.apache.org