You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by ma...@apache.org on 2004/02/20 13:42:48 UTC
cvs commit: jakarta-velocity-tools/examples/struts/WEB-INF/src/examples/app1 AddressAction.java AddressBean.java AddressForm.java
marino 2004/02/20 04:42:48
Modified: examples/struts/WEB-INF/src/examples/app1 AddressAction.java
AddressBean.java AddressForm.java
Log:
use Apache Software License 2.0
Revision Changes Path
1.3 +23 -14 jakarta-velocity-tools/examples/struts/WEB-INF/src/examples/app1/AddressAction.java
Index: AddressAction.java
===================================================================
RCS file: /home/cvs/jakarta-velocity-tools/examples/struts/WEB-INF/src/examples/app1/AddressAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AddressAction.java 22 Jul 2003 05:16:40 -0000 1.2
+++ AddressAction.java 20 Feb 2004 12:42:47 -0000 1.3
@@ -1,10 +1,19 @@
/*
- * Struts Example Application 1
- *
- * This demonstrates the use of Velocity templates with the Struts framework.
+ * Copyright 2003 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 examples.app1;
@@ -40,12 +49,12 @@
* <li>edit - edit address record
* <li>save - save address record
* </ul>
- *
+ *
*
* @author <a href="mailto:sidler@teamup.com"/>Gabe Sidler</a>
* @version $Id$
*/
-public class AddressAction extends Action
+public class AddressAction extends Action
{
// --------------------------------------------------------- Public Methods
@@ -75,7 +84,7 @@
try
{
session = request.getSession();
-
+
// fetch action from form
action = ((AddressForm)form).getAction();
@@ -86,19 +95,19 @@
{
// forward to edit formular
return (mapping.findForward("editAddress"));
-
+
}
else if (action.equals("save"))
{
// check if an address bean exits already
AddressBean bean = (AddressBean)session.getAttribute("address");
-
+
if (bean == null)
{
bean = new AddressBean();
session.setAttribute("address", bean);
}
-
+
// update bean with the new values submitted
bean.setFirstname( ((AddressForm)form).getFirstname() );
bean.setLastname( ((AddressForm)form).getLastname() );
@@ -110,7 +119,7 @@
// forward to list
return (mapping.findForward("showAddress"));
-
+
}
else
{
@@ -119,9 +128,9 @@
session.setAttribute(Globals.LOCALE_KEY, new Locale("de", ""));
else
session.setAttribute(Globals.LOCALE_KEY, new Locale("en", ""));
-
+
// forward to edit formular
- return (mapping.findForward("showAddress"));
+ return (mapping.findForward("showAddress"));
}
}
catch (Exception e)
1.2 +46 -37 jakarta-velocity-tools/examples/struts/WEB-INF/src/examples/app1/AddressBean.java
Index: AddressBean.java
===================================================================
RCS file: /home/cvs/jakarta-velocity-tools/examples/struts/WEB-INF/src/examples/app1/AddressBean.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AddressBean.java 6 Mar 2003 00:05:18 -0000 1.1
+++ AddressBean.java 20 Feb 2004 12:42:47 -0000 1.2
@@ -1,10 +1,19 @@
/*
- * Struts Example Application 1
- *
- * This demonstrates the use of Velocity templates with the Struts framework.
+ * Copyright 2003 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 examples.app1;
@@ -24,108 +33,108 @@
* @version $Id$
*/
-public class AddressBean extends Object
+public class AddressBean extends Object
{
// ---- Fields ------------------------------------------------------
private String firstname;
-
+
private String lastname;
private String street;
-
+
private String zip;
-
+
private String city;
-
+
private String country;
-
+
private String[] languages;
-
+
// ---- Accessor Methods --------------------------------------------
-
+
public String getFirstname()
{
return firstname;
-
+
}
-
+
public void setFirstname(String s)
{
firstname = s;
-
+
}
-
+
public String getLastname()
{
return lastname;
-
+
}
-
+
public void setLastname(String s)
{
lastname = s;
-
+
}
public String getStreet()
{
return street;
-
+
}
-
+
public void setStreet(String s)
{
street = s;
-
+
}
public String getZip()
{
return zip;
-
+
}
-
+
public void setZip(String s)
{
zip = s;
-
+
}
public String getCity()
{
return city;
-
+
}
-
+
public void setCity(String s)
{
city = s;
-
+
}
public String getCountry()
{
return country;
-
+
}
-
+
public void setCountry(String s)
{
country = s;
-
+
}
public String[] getLanguages()
{
return languages;
}
-
+
public void setLanguages(String[] languages)
{
- this.languages = languages;
+ this.languages = languages;
}
// Convenience method to simplify repopulation of select lists
@@ -136,10 +145,10 @@
{
for (int i = 0; i < languages.length; i++)
p.setProperty((String)languages[i], "SELECTED");
- }
+ }
return p;
- }
-
+ }
+
}
1.2 +38 -29 jakarta-velocity-tools/examples/struts/WEB-INF/src/examples/app1/AddressForm.java
Index: AddressForm.java
===================================================================
RCS file: /home/cvs/jakarta-velocity-tools/examples/struts/WEB-INF/src/examples/app1/AddressForm.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AddressForm.java 6 Mar 2003 00:05:18 -0000 1.1
+++ AddressForm.java 20 Feb 2004 12:42:47 -0000 1.2
@@ -1,10 +1,19 @@
/*
- * Struts Example Application 1
- *
- * This demonstrates the use of Velocity templates with the Struts framework.
+ * Copyright 2003 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 examples.app1;
@@ -24,57 +33,57 @@
* @version $Id$
*/
-public final class AddressForm extends ActionForm
+public final class AddressForm extends ActionForm
{
// ---- Form fields -------------------------------------------------
-
+
private String action = "";
-
+
private String firstname = "";
-
+
private String lastname = "";
private String street = "";
-
+
private String zip = "";
-
+
private String city = "";
-
+
private String country = "";
-
+
private String locale = "";
-
+
private String[] languages;
-
+
// ---- Accessor Methods --------------------------------------------
-
+
public String getAction()
{
return action;
}
-
+
public void setAction(String s)
{
action = s;
}
-
+
public String getFirstname()
{
return firstname;
}
-
+
public void setFirstname(String s)
{
firstname = s;
}
-
+
public String getLastname()
{
return lastname;
}
-
+
public void setLastname(String s)
{
lastname = s;
@@ -84,7 +93,7 @@
{
return street;
}
-
+
public void setStreet(String s)
{
street = s;
@@ -94,7 +103,7 @@
{
return zip;
}
-
+
public void setZip(String s)
{
zip = s;
@@ -104,7 +113,7 @@
{
return city;
}
-
+
public void setCity(String s)
{
city = s;
@@ -114,7 +123,7 @@
{
return country;
}
-
+
public void setCountry(String s)
{
country = s;
@@ -124,7 +133,7 @@
{
return locale;
}
-
+
public void setLocale(String s)
{
locale = s;
@@ -134,12 +143,12 @@
{
return languages;
}
-
+
public void setLanguages(String[] s)
{
languages = s;
}
-
+
/**
* Reset all properties to their default values.
@@ -147,7 +156,7 @@
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
*/
- public void reset(ActionMapping mapping, HttpServletRequest request)
+ public void reset(ActionMapping mapping, HttpServletRequest request)
{
action = "";
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org