Added: 
struts/sandbox/trunk/ti/samples/src/java/org/apache/ti/samples/pageflow/loginexample/ExampleLoginHandler.java
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/samples/src/java/org/apache/ti/samples/pageflow/loginexample/ExampleLoginHandler.java?rev=240168&view=auto
==============================================================================
--- 
struts/sandbox/trunk/ti/samples/src/java/org/apache/ti/samples/pageflow/loginexample/ExampleLoginHandler.java
 (added)
+++ 
struts/sandbox/trunk/ti/samples/src/java/org/apache/ti/samples/pageflow/loginexample/ExampleLoginHandler.java
 Thu Aug 25 22:46:03 2005
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2004-2005 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.
+ *
+ * $Header:$
+ */
+package org.apache.ti.samples.pageflow.loginexample;
+
+import javax.security.auth.login.LoginException;
+import java.security.Principal;
+import java.util.Map;
+
+import org.apache.ti.pageflow.handler.BaseHandler;
+import org.apache.ti.pageflow.handler.LoginHandler;
+import org.apache.ti.pageflow.xwork.PageFlowActionContext;
+
+public class ExampleLoginHandler
+    extends BaseHandler
+    implements LoginHandler
+{
+    private static class UserPrincipal
+        implements Principal
+    {
+        public String getName()
+        {
+            return "good";
+        }
+    }
+
+    public void login( String username, String password )
+        throws LoginException
+    {
+        if ( username.equals("good") && password.equals("good") )
+        {
+            Map sessionScope = PageFlowActionContext.get().getSessionScope();
+            sessionScope.put("_principal", new UserPrincipal());
+        }
+        else
+        {
+            throw new LoginException( username );
+        }
+    }
+
+    public void logout( boolean invalidateSessions )
+    {
+        PageFlowActionContext.get().getSessionScope().remove("_principal");
+    }
+
+    public boolean isUserInRole(String roleName)
+    {
+        return false;
+    }
+
+    public Principal getUserPrincipal()
+    {
+        return (Principal) 
PageFlowActionContext.get().getSessionScope().get("_principal");
+    }
+}

Added: struts/sandbox/trunk/ti/samples/src/java/pageflow/basic/Controller.java
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/samples/src/java/pageflow/basic/Controller.java?rev=240168&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/samples/src/java/pageflow/basic/Controller.java 
(added)
+++ struts/sandbox/trunk/ti/samples/src/java/pageflow/basic/Controller.java Thu 
Aug 25 22:46:03 2005
@@ -0,0 +1,43 @@
+package pageflow.basic;
+
+import org.apache.ti.pageflow.annotations.ti;
+import org.apache.ti.pageflow.PageFlowController;
+import org.apache.ti.pageflow.Forward;
+import com.opensymphony.xwork.Action;
+
[EMAIL PROTECTED](
+    handleExceptions={
+        @ti.handleException(type=Controller.CustomException.class, 
path="error.jsp"),
+        @ti.handleException(type=ArithmeticException.class, 
method="handleArithmeticException")
+    }
+)
+public class Controller extends PageFlowController {
+
+    @ti.action
+    public String someAction() {
+        return Action.SUCCESS;
+    }
+
+    static class CustomException extends Exception {}
+    static class IntentionalException extends CustomException {}
+
+    @ti.action
+    public String throw1() throws IntentionalException {
+        throw new IntentionalException();  // caught by the 
@ti.handleException for CustomException
+    }
+
+    @ti.action
+    public String throw2() {
+        throw new ArithmeticException("intentional");
+    }
+
+    @ti.exceptionHandler
+    public String handleArithmeticException(ArithmeticException e, String 
message) {
+        return Action.SUCCESS;
+    }
+}
+
+/*
+ (See /WEB-INF/src/_pageflow-config/pageflow/basic/xwork.xml for a mockup of 
the generated config.)
+ */
+

Added: 
struts/sandbox/trunk/ti/samples/src/java/pageflow/formBean/Controller.java
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/samples/src/java/pageflow/formBean/Controller.java?rev=240168&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/samples/src/java/pageflow/formBean/Controller.java 
(added)
+++ struts/sandbox/trunk/ti/samples/src/java/pageflow/formBean/Controller.java 
Thu Aug 25 22:46:03 2005
@@ -0,0 +1,27 @@
+package pageflow.formBean;
+
+import org.apache.ti.pageflow.annotations.ti;
+import org.apache.ti.pageflow.PageFlowController;
+import org.apache.ti.pageflow.Forward;
+import com.opensymphony.xwork.Action;
+import java.io.Serializable;
+
[EMAIL PROTECTED]
+public class Controller extends PageFlowController {
+
+    public static class MyBean implements Serializable {
+        private String _foo;
+        public void setFoo(String foo) { _foo = foo; }
+        public String getFoo() { return _foo; }
+    }
+
+    @ti.action
+    public Forward submit(MyBean bean) {
+        return new Forward(Action.SUCCESS, "result", bean.getFoo());
+    }
+}
+
+/*
+ (See /WEB-INF/src/_pageflow-config/pageflow/formBean/xwork.xml for a mockup 
of the generated config.)
+ */
+

Added: 
struts/sandbox/trunk/ti/samples/src/java/pageflow/loginexample/loginflow/Controller.java
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/samples/src/java/pageflow/loginexample/loginflow/Controller.java?rev=240168&view=auto
==============================================================================
--- 
struts/sandbox/trunk/ti/samples/src/java/pageflow/loginexample/loginflow/Controller.java
 (added)
+++ 
struts/sandbox/trunk/ti/samples/src/java/pageflow/loginexample/loginflow/Controller.java
 Thu Aug 25 22:46:03 2005
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2004-2005 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.
+ *
+ * $Header:$
+ */
+package pageflow.loginexample.loginflow;
+
+import javax.security.auth.login.LoginException;
+
+import org.apache.ti.pageflow.annotations.ti;
+import org.apache.ti.pageflow.PageFlowController;
+import org.apache.ti.pageflow.Forward;
+
[EMAIL PROTECTED](
+    nested=true,
+    simpleActions={
+        @ti.simpleAction(name="cancel", returnAction="loginCancel")
+    },
+    handleExceptions={
+        @ti.handleException(type=LoginException.class, path="begin.jsp")
+    },
+    messageBundles={
+        
@ti.messageBundle(bundlePath="org.apache.beehive.samples.netui.resources.loginexample.messages")
+    }
+)
+public class Controller extends PageFlowController
+{
+    @ti.action(
+        forwards={
+            @ti.forward(name="success", returnAction="loginSuccess")
+        },
+        [EMAIL PROTECTED](name="failure", path="begin.jsp")
+    )
+    public Forward login( LoginForm form )
+        throws LoginException
+    {
+        // This ultimately calls login on 
org.apache.beehive.samples.netui.login.ExampleLoginHandler.
+        login( form.getUsername(), form.getPassword() );
+        return new Forward( "success" );
+    }
+
+    public static class LoginForm implements java.io.Serializable
+    {
+        private String _username;
+        private String _password;
+
+        @ti.validatableProperty(
+            // We could have also used the 'displayName' attribute -- a 
hardcoded string or a 
+            // JSP 2.0-style expression.
+            displayNameKey="displaynames.username",
+            [EMAIL PROTECTED](),
+            [EMAIL PROTECTED](chars=4)
+        )
+        public String getUsername()
+        {
+            return _username;
+        }
+
+        public void setUsername( String username )
+        {
+            _username = username;
+        }
+
+        @ti.validatableProperty(
+            displayNameKey="displaynames.password",
+            [EMAIL PROTECTED](),
+            [EMAIL PROTECTED](chars=4)
+        )
+        public String getPassword()
+        {
+            return _password;
+        }
+
+        public void setPassword( String password )
+        {
+            _password = password;
+        }
+    }
+}

Added: 
struts/sandbox/trunk/ti/samples/src/java/pageflow/loginexample/protectedflow/Controller.java
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/samples/src/java/pageflow/loginexample/protectedflow/Controller.java?rev=240168&view=auto
==============================================================================
--- 
struts/sandbox/trunk/ti/samples/src/java/pageflow/loginexample/protectedflow/Controller.java
 (added)
+++ 
struts/sandbox/trunk/ti/samples/src/java/pageflow/loginexample/protectedflow/Controller.java
 Thu Aug 25 22:46:03 2005
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2004-2005 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.
+ *
+ * $Header:$
+ */
+package pageflow.loginexample.protectedflow;
+
+import org.apache.ti.pageflow.annotations.ti;
+import org.apache.ti.pageflow.PageFlowController;
+
[EMAIL PROTECTED](
+    nested=true,
+    loginRequired=true,     // just in case someone hits this directly -- 
unused in the scenario
+    simpleActions={
+        @ti.simpleAction(name="done", returnAction="protectedFlowDone")
+    }
+)
+public class Controller extends PageFlowController
+{
+}

Added: 
struts/sandbox/trunk/ti/samples/src/java/pageflow/loginexample/start/Controller.java
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/samples/src/java/pageflow/loginexample/start/Controller.java?rev=240168&view=auto
==============================================================================
--- 
struts/sandbox/trunk/ti/samples/src/java/pageflow/loginexample/start/Controller.java
 (added)
+++ 
struts/sandbox/trunk/ti/samples/src/java/pageflow/loginexample/start/Controller.java
 Thu Aug 25 22:46:03 2005
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2004-2005 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.
+ *
+ * $Header:$
+ */
+package pageflow.loginexample.start;
+
+import org.apache.ti.pageflow.annotations.ti;
+import org.apache.ti.samples.pageflow.loginexample.BaseFlow;
+
+/**
+ * Note that this page flow inherits actions and a handleException from 
BaseFlow.
+ */
[EMAIL PROTECTED](
+    simpleActions={
+        @ti.simpleAction(name="goProtectedFlow", 
path="/pageflow/loginexample/protectedflow/Controller.jpf", loginRequired=true),
+        @ti.simpleAction(name="protectedFlowDone", 
navigateTo=ti.NavigateTo.currentPage)
+    }
+)
+public class Controller extends BaseFlow
+{
+}

Added: struts/sandbox/trunk/ti/samples/src/java/pageflow/nesting/Controller.java
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/samples/src/java/pageflow/nesting/Controller.java?rev=240168&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/samples/src/java/pageflow/nesting/Controller.java 
(added)
+++ struts/sandbox/trunk/ti/samples/src/java/pageflow/nesting/Controller.java 
Thu Aug 25 22:46:03 2005
@@ -0,0 +1,55 @@
+/*
+   Copyright 2005 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.
+
+   $Header:$
+*/
+package pageflow.nesting;
+
+import org.apache.ti.pageflow.PageFlowController;
+import org.apache.ti.pageflow.Forward;
+import org.apache.ti.pageflow.annotations.ti;
+import pageflow.nesting.chooseAirport.ChooseAirport;
+import com.opensymphony.xwork.Action;
+
+/**
+ * Main page flow, which invokes a nested page flow and gets data back from it.
+ */
[EMAIL PROTECTED](
+    simpleActions={
+        // This action runs the Choose Airport wizard.  Since the 
ChooseAirport page flow is marked
+        // with nested=true, it will be able to return control to this page 
flow when it is done.
+        @ti.simpleAction(name="chooseAirport", 
path="/pageflow/nesting/chooseAirport/ChooseAirport.jpf"),
+
+        // This action is raised by the ChooseAirport page flow  The 
navigateTo attribute here
+        // causes flow to return to the current page in this page flow.
+        @ti.simpleAction(name="chooseAirportCancelled", 
navigateTo=ti.NavigateTo.currentPage)
+    }
+)
+public class Controller extends PageFlowController
+{
+    // This property ("yourName") is used in the JSPs to show that this page 
flow's state is
+    // restored when you return from the nested flow.
+    private String _yourName;
+    public String getYourName() { return _yourName; }
+    public void setYourName(String yourName) { _yourName = yourName; }
+
+    @ti.action
+    protected Forward chooseAirportDone( ChooseAirport.Results results )
+    {
+        Forward fwd = new Forward(Action.SUCCESS);
+        fwd.addActionOutput("airport", results.getAirport());
+        return fwd;
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to