You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(16) |
Sep
(10) |
Oct
(1) |
Nov
(2) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(148) |
Feb
(80) |
Mar
(41) |
Apr
(85) |
May
(247) |
Jun
(345) |
Jul
(237) |
Aug
(241) |
Sep
(439) |
Oct
(321) |
Nov
(413) |
Dec
(302) |
2004 |
Jan
(143) |
Feb
(147) |
Mar
(200) |
Apr
(107) |
May
(15) |
Jun
(36) |
Jul
(11) |
Aug
(1) |
Sep
(36) |
Oct
|
Nov
(6) |
Dec
|
2005 |
Jan
|
Feb
|
Mar
|
Apr
(115) |
May
(74) |
Jun
(215) |
Jul
(82) |
Aug
(47) |
Sep
(32) |
Oct
(8) |
Nov
(70) |
Dec
(24) |
2006 |
Jan
|
Feb
(1) |
Mar
(4) |
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jm...@us...> - 2005-08-04 07:45:28
|
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/wizard/accounts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20952/src/net/jspcontrols/dialogs/samples/wizard/accounts Added Files: UserAccounts.java Log Message: --- NEW FILE: UserAccounts.java --- /* * Copyright 2004-2005 Michael Jouravlev. * * 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 net.jspcontrols.dialogs.samples.wizard.accounts; import javax.servlet.http.HttpSession; import javax.servlet.ServletContext; import java.util.ArrayList; import java.util.Iterator; /** * This class manages user login, logout, and validation. It also stores * user accounts in the servlet context (this is just a demo). * * @author Michael Jouravlev */ public class UserAccounts { /** * Maximum number of user accounts */ public static final int MAX_ACCOUNTS = 1000; /** * Key to store user accounts in the servlet context */ private static final String USERACCOUNT_KEY = "login.useraccounts"; /** * Key to store user login name in the session */ private static final String LOGIN_KEY = "login.username"; /** * Check if login name/password combination is registered. * * @param loginInfo existing user accounts, in real application would be * loaded from database. * @param name user name to check * @param pwd user password to check * @param newSignup true if registering new account, in this case * password do not need to be validated against * existing user account. * * @return true if name exists and password matches existing password * (if checking existing account); false otherwise. */ static private boolean findUserName(ArrayList loginInfo, String name, String pwd, boolean newSignup) { // TODO: Use map instead of arraylist boolean pwdOK = false; if (loginInfo != null && loginInfo.size() > 0) { Iterator itLogin = loginInfo.iterator(); while (itLogin.hasNext()) { String[] nameAndPwd = (String[]) itLogin.next(); /* * For new signup password must simply exist, for login * password must match the password in existing account. */ pwdOK = newSignup ? pwd != null : pwd != null && pwd.equals(nameAndPwd[1]); if (name != null && name.equals(nameAndPwd[0]) && pwdOK) { return true; } } } return false; } static public boolean checkNameOnSignup(HttpSession session, String name, String password) { // Login information is stored in servlet context ServletContext context = session.getServletContext(); ArrayList globalLoginInfo = getLoginInfo(context); // User is already defined return !findUserName(globalLoginInfo, name, password, true); } /** * Adds a new user and returns error status * * @param session used to obtain servlet context where this demo * stores user accounts * @param name new user name * @param password user's password * @param securityAnswerId user's favorite book * @param securityAnswer user's favorite movie * * @return true if added successfully, false otherwise */ synchronized static public boolean addUser(HttpSession session, String name, String password, int securityAnswerId, String securityAnswer, boolean keepLoggedIn) { String strAnswerId = Integer.toString(securityAnswerId); // Storing login information as array in the login map String[] newLogin = new String[] {name, password, strAnswerId, securityAnswer}; // Login information is stored in servlet context ServletContext context = session.getServletContext(); ArrayList globalLoginInfo = getLoginInfo(context); // User is already defined if (findUserName(globalLoginInfo, name, password, true)) { return false; } // Store login name/password for a new user globalLoginInfo.add(newLogin); context.setAttribute(USERACCOUNT_KEY, globalLoginInfo); // Set user name in the session, effectively logging the user in. // User page scriptlet checks this session attribute before // displaying user home page. if (keepLoggedIn) { session.setAttribute(LOGIN_KEY, name); } return true; } private static ArrayList getLoginInfo(ServletContext context) { ArrayList globalLoginInfo = (ArrayList) context.getAttribute(USERACCOUNT_KEY); /* * If no user accounts defined, create a new one. Also, clear all * accounts from the servlet context when too much users registered */ if (globalLoginInfo == null || globalLoginInfo.size() > MAX_ACCOUNTS) { globalLoginInfo = new ArrayList(); } return globalLoginInfo; } /** * Tries to log the user in * * @param session session object where user login is stored * @param name user name * @param password user password * * @return true if logged in successfully, false otherwise */ synchronized public static boolean login(HttpSession session, String name, String password) { /* * Clear any previous login information in the session, * so if login is unsuccessful, a user would be logged out. */ session.removeAttribute(LOGIN_KEY); /* * Load existing name/password combinations from storage */ ArrayList globalLoginInfo = (ArrayList) session.getServletContext().getAttribute( USERACCOUNT_KEY ); /* * Search for defined name/password. If found, set * user name in the session, effectively logging the user in. */ if (findUserName(globalLoginInfo, name, password, false)) { session.setAttribute(LOGIN_KEY, name); return true; } else { return false; } } /** * Logs the user out * @param session session object where user login is stored */ synchronized public static void logout(HttpSession session) { session.removeAttribute(LOGIN_KEY); } /** * Returns the name of currently logged in user * @return the name of current user */ synchronized public static String currentUser(HttpSession session) { return (String) session.getAttribute(LOGIN_KEY); } } |
From: <jm...@us...> - 2005-08-04 07:45:28
|
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/selectaction In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20952/src/net/jspcontrols/dialogs/samples/selectaction Added Files: SelectActionSample.java Log Message: --- NEW FILE: SelectActionSample.java --- /* * Copyright 2004-2005 Michael Jouravlev * * 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 net.jspcontrols.dialogs.samples.selectaction; import javax.servlet.ServletException; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletRequest; import java.util.Map; import java.util.HashMap; import java.io.IOException; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForward; import net.jspcontrols.dialogs.actions.SelectAction; /** * Example of DispathQueryAction usage */ public class SelectActionSample extends SelectAction { // Define button -> method mapping protected Map getKeyMethodMap() { Map map = new HashMap(); map.put(getInitKey() + "-ADD", "add"); map.put(getInitKey() + "-DELETE", "delete"); map.put(getInitKey() + "-LOGIN", "login"); map.put(getInitKey() + "-CANCEL", "cancel"); return map; } // Handler of Add button public ActionForward add(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { return mapping.findForward("addpage"); } // Handler of classic DispatchAction Add button public ActionForward Add(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { return mapping.findForward("addpage"); } // Handler of Delete button public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { return mapping.findForward("deletepage"); } // Handler of Login button public ActionForward login(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { return mapping.findForward("loginpage"); } // Handler of standard Cancel button public ActionForward cancelled(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { return mapping.findForward("cancelpage"); } // Handler of unknown button public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { return mapping.findForward("unspecifiedpage"); } } |
From: <jm...@us...> - 2005-08-04 07:45:28
|
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/embedded In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20952/src/net/jspcontrols/dialogs/samples/embedded Added Files: EmbeddedControl.java EmbeddedControlResin.java EmbeddedControlTomcat.java embedded_0002dchild_0002dlogin_jsp.java embedded_0002dchild_0002dlogout_jsp.java Log Message: --- NEW FILE: EmbeddedControl.java --- /* * Copyright 2004-2005 Michael Jouravlev * * 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 net.jspcontrols.dialogs.samples.embedded; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMessages; import org.apache.jasper.runtime.HttpJspBase; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.util.Map; import java.util.HashMap; import net.jspcontrols.dialogs.actions.DialogConstants; import net.jspcontrols.dialogs.actions.DialogAction; import net.jspcontrols.dialogs.samples.login.LoginForm; /** * <p>This is a parent class for two concrete embedded controls: one is fully * JSP-compliant and works in Tomcat, another uses features above JSP spec, * implemented, for example, in Resin or Jetty.</p> * * <p>This is a login control with two states and two corresponding pages: * "logged in" and "not logged in".</p> * * @author Michael Jouravlev */ public class EmbeddedControl extends DialogAction { /** * Maps submit button names to methods */ protected Map getKeyMethodMap() { Map map = new HashMap(); // Submit events map.put("DIALOG-EVENT-LOGIN", "login"); map.put("DIALOG-EVENT-LOGOUT", "logout"); return map; } /** * Process login attempt (POST) and reloads the master page */ public ActionForward login ( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Validate user name and password, can do it right here in action as well ActionMessages errors = form.validate(mapping, request); // Errors found, stick them into session if (errors != null) { HttpSession session = request.getSession(); saveDialogErrors(session, errors); // Login OK, set username in the session } else { LoginForm inputForm = (LoginForm) form; request.getSession().setAttribute("login.username", inputForm.getName()); } // Reload master page, see mapping in struts_config.xml return mapping.findForward(DialogConstants.DIALOG_RELOAD_KEY); } /** * Logs a user out and reloads the master page */ public ActionForward logout (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { LoginForm inputForm = (LoginForm) form; // Clean password in the input/output form bean inputForm.setPassword(null); // Remove login name from session, effectively logging out request.getSession().removeAttribute("login.username"); // Reload master page, see mapping in struts_config.xml return mapping.findForward(DialogConstants.DIALOG_RELOAD_KEY); } } --- NEW FILE: EmbeddedControlResin.java --- /* * Copyright 2004-2005 Michael Jouravlev * * 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 net.jspcontrols.dialogs.samples.embedded; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * <p>This is a login control uses features above JSP spec, implemented, * for example, in Resin or Jetty. The control has two states and two * corresponding pages: "logged in" and "not logged in".</p> * * @author Michael Jouravlev */ public class EmbeddedControlResin extends EmbeddedControl { /** * <p>Renders embedded control in a way, which is not compliant with JSP spec * up to 2.4. Therefore, this render method does not work on Tomcat. * JSP specification, version 2.4, section 8.4 reads: * "Before the forward method of the RequestDispatcher interface * returns, the response content must be sent and committed, * and closed by the servlet container."</p> * * <p>The above means, that when embedded component of master JSP page * (this action class) forwards to its own little JSP page to render * itself, Tomcat closes response, and the rest of master page * is not rendered. This should be addressed in future JSP spec.</p> * * <p>The code works fine in Resin, but does not work in Tomcat * without a patch. Patch is available, but was not thoroughly tested.</p> * * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * @return action mapping to a page, corresponding to current control * state: "notlogggedin" or "loggedin". */ public ActionForward getDialogView(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Mark component as non-cachable setNoCache(response); // Display page, corresponding to login state. HttpSession session = request.getSession(); if (session.getAttribute("login.username") == null) { return mapping.findForward("notloggedin"); } else { return mapping.findForward("loggedin"); } } } --- NEW FILE: EmbeddedControlTomcat.java --- /* * Copyright 2004-2005 Michael Jouravlev * * 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 net.jspcontrols.dialogs.samples.embedded; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMessages; import org.apache.jasper.runtime.HttpJspBase; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.util.Map; import java.util.HashMap; import net.jspcontrols.dialogs.actions.DialogConstants; import net.jspcontrols.dialogs.actions.DialogAction; import net.jspcontrols.dialogs.samples.login.LoginForm; /** * <p>This is a login control which is fully JSP-compliant and works in * Tomcat. The control has two states and two corresponding pages: * "logged in" and "not logged in".</p> * * @author Michael Jouravlev */ public class EmbeddedControlTomcat extends EmbeddedControl { /** * <p>Renders embedded control in a way, which is compliant with JSP spec. * JSP specification, version 2.4, section 8.4 reads: * "Before the forward method of the RequestDispatcher interface * returns, the response content must be sent and committed, * and closed by the servlet container."</p> * * <p>The above means, that included action form should not forward * to JSP page for rendering, instead it must render page itself.</p> * * <p>The code works fine in any JSP container.</p> * * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * @return action mapping to a page, corresponding to current control * state: "notlogggedin" or "loggedin". */ public ActionForward getDialogView(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Mark component as non-cachable setNoCache(response); // Use code that was generated by Jasper from JSP pages. // Invoke it directly to avoid forwarding and premature closure // of response object. // While this is not the best way to develop JSP controls, it works. // Hopefully JSP spec will be fixed to allow forwarding from // included component. HttpSession session = request.getSession(); HttpJspBase resultPage = null; if (session.getAttribute("login.username") == null) { resultPage = new embedded_0002dchild_0002dlogin_jsp(); } else { resultPage = new embedded_0002dchild_0002dlogout_jsp(); } resultPage.init(this.getServlet().getServletConfig()); resultPage._jspService(request, response); resultPage.destroy(); return null; } } --- NEW FILE: embedded_0002dchild_0002dlogin_jsp.java --- /* * Struts Dialogs, login control sample. * This file was generated by Apache Jasper. */ package net.jspcontrols.dialogs.samples.embedded; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; import org.apache.jasper.runtime.*; public class embedded_0002dchild_0002dlogin_jsp extends HttpJspBase { private static java.util.Vector _jspx_includes; private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_html_form_action; private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_logic_messagesPresent; private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_html_messages_id; private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_bean_write_name_nobody; private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_html_text_tabindex_size_property_name_nobody; private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_html_image_value_src_property_nobody; public embedded_0002dchild_0002dlogin_jsp() { _jspx_tagPool_html_form_action = new org.apache.jasper.runtime.TagHandlerPool(); _jspx_tagPool_logic_messagesPresent = new org.apache.jasper.runtime.TagHandlerPool(); _jspx_tagPool_html_messages_id = new org.apache.jasper.runtime.TagHandlerPool(); _jspx_tagPool_bean_write_name_nobody = new org.apache.jasper.runtime.TagHandlerPool(); _jspx_tagPool_html_text_tabindex_size_property_name_nobody = new org.apache.jasper.runtime.TagHandlerPool(); _jspx_tagPool_html_image_value_src_property_nobody = new org.apache.jasper.runtime.TagHandlerPool(); } public java.util.List getIncludes() { return _jspx_includes; } public void _jspDestroy() { _jspx_tagPool_html_form_action.release(); _jspx_tagPool_logic_messagesPresent.release(); _jspx_tagPool_html_messages_id.release(); _jspx_tagPool_bean_write_name_nobody.release(); _jspx_tagPool_html_text_tabindex_size_property_name_nobody.release(); _jspx_tagPool_html_image_value_src_property_nobody.release(); } public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspFactory _jspxFactory = null; javax.servlet.jsp.PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; try { _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/html;charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("<!--\r\n Struts Dialogs, Login Control example\r\n Author: Michael Jouravlev, 2004-2005\r\n\r\n This is \"Login Page\" view for login embedded control\r\n-->\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n\r\n"); out.write("<table width=100% border=0 celpadding=0 cellspacing=2>\r\n "); /* ---- html:form ---- */ org.apache.struts.taglib.html.FormTag _jspx_th_html_form_0 = (org.apache.struts.taglib.html.FormTag) _jspx_tagPool_html_form_action.get(org.apache.struts.taglib.html.FormTag.class); _jspx_th_html_form_0.setPageContext(pageContext); _jspx_th_html_form_0.setParent(null); _jspx_th_html_form_0.setAction("/embeddedchild-tomcat.do"); int _jspx_eval_html_form_0 = _jspx_th_html_form_0.doStartTag(); if (_jspx_eval_html_form_0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { do { out.write("\r\n "); out.write("<!-- Standard Struts error handling -->\r\n "); /* ---- logic:messagesPresent ---- */ org.apache.struts.taglib.logic.MessagesPresentTag _jspx_th_logic_messagesPresent_0 = (org.apache.struts.taglib.logic.MessagesPresentTag) _jspx_tagPool_logic_messagesPresent.get(org.apache.struts.taglib.logic.MessagesPresentTag.class); _jspx_th_logic_messagesPresent_0.setPageContext(pageContext); _jspx_th_logic_messagesPresent_0.setParent(_jspx_th_html_form_0); int _jspx_eval_logic_messagesPresent_0 = _jspx_th_logic_messagesPresent_0.doStartTag(); if (_jspx_eval_logic_messagesPresent_0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { do { out.write("\r\n "); out.write("<tr>\r\n "); out.write("<td colspan=\"2\" align=\"left\" bgcolor=\"#FF9966\">\r\n "); /* ---- html:messages ---- */ org.apache.struts.taglib.html.MessagesTag _jspx_th_html_messages_0 = (org.apache.struts.taglib.html.MessagesTag) _jspx_tagPool_html_messages_id.get(org.apache.struts.taglib.html.MessagesTag.class); _jspx_th_html_messages_0.setPageContext(pageContext); _jspx_th_html_messages_0.setParent(_jspx_th_logic_messagesPresent_0); _jspx_th_html_messages_0.setId("error"); int _jspx_eval_html_messages_0 = _jspx_th_html_messages_0.doStartTag(); if (_jspx_eval_html_messages_0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { java.lang.String error = null; if (_jspx_eval_html_messages_0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) { javax.servlet.jsp.tagext.BodyContent _bc = pageContext.pushBody(); out = _bc; _jspx_th_html_messages_0.setBodyContent(_bc); _jspx_th_html_messages_0.doInitBody(); } error = (java.lang.String) pageContext.findAttribute("error"); do { out.write("\r\n "); if (_jspx_meth_bean_write_0(_jspx_th_html_messages_0, pageContext)) return; out.write("\r\n "); int evalDoAfterBody = _jspx_th_html_messages_0.doAfterBody(); error = (java.lang.String) pageContext.findAttribute("error"); if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break; } while (true); if (_jspx_eval_html_messages_0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) out = pageContext.popBody(); } if (_jspx_th_html_messages_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) return; _jspx_tagPool_html_messages_id.reuse(_jspx_th_html_messages_0); out.write("\r\n "); out.write("</td>\r\n "); out.write("</tr>\r\n "); int evalDoAfterBody = _jspx_th_logic_messagesPresent_0.doAfterBody(); if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break; } while (true); } if (_jspx_th_logic_messagesPresent_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) return; _jspx_tagPool_logic_messagesPresent.reuse(_jspx_th_logic_messagesPresent_0); out.write("\r\n "); out.write("<tr>\r\n "); out.write("<td align=\"left\">User name:"); out.write("</td>\r\n "); out.write("<td align=\"left\">\r\n "); if (_jspx_meth_html_text_0(_jspx_th_html_form_0, pageContext)) return; out.write("\r\n "); out.write("</td>\r\n "); out.write("</tr>\r\n "); out.write("<tr>\r\n "); out.write("<td align=\"left\">User pasword:"); out.write("</td>\r\n "); out.write("<td align=\"left\">\r\n "); if (_jspx_meth_html_text_1(_jspx_th_html_form_0, pageContext)) return; out.write("\r\n "); out.write("</td>\r\n "); out.write("</tr>\r\n "); out.write("<tr>\r\n "); out.write("<td align=\"left\">Use \"guest\"/\"guest\""); out.write("</td>\r\n "); out.write("<td colspan=\"2\" align=\"left\">\r\n "); if (_jspx_meth_html_image_0(_jspx_th_html_form_0, pageContext)) return; out.write("\r\n "); out.write("</td>\r\n "); out.write("</tr>\r\n "); int evalDoAfterBody = _jspx_th_html_form_0.doAfterBody(); if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break; } while (true); } if (_jspx_th_html_form_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) return; _jspx_tagPool_html_form_action.reuse(_jspx_th_html_form_0); out.write("\r\n"); out.write("</table>\r\n"); } catch (Throwable t) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (pageContext != null) pageContext.handlePageException(t); } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext); } } private boolean _jspx_meth_bean_write_0(javax.servlet.jsp.tagext.Tag _jspx_th_html_messages_0, javax.servlet.jsp.PageContext pageContext) throws Throwable { JspWriter out = pageContext.getOut(); /* ---- bean:write ---- */ org.apache.struts.taglib.bean.WriteTag _jspx_th_bean_write_0 = (org.apache.struts.taglib.bean.WriteTag) _jspx_tagPool_bean_write_name_nobody.get(org.apache.struts.taglib.bean.WriteTag.class); _jspx_th_bean_write_0.setPageContext(pageContext); _jspx_th_bean_write_0.setParent(_jspx_th_html_messages_0); _jspx_th_bean_write_0.setName("error"); int _jspx_eval_bean_write_0 = _jspx_th_bean_write_0.doStartTag(); if (_jspx_th_bean_write_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) return true; _jspx_tagPool_bean_write_name_nobody.reuse(_jspx_th_bean_write_0); return false; } private boolean _jspx_meth_html_text_0(javax.servlet.jsp.tagext.Tag _jspx_th_html_form_0, javax.servlet.jsp.PageContext pageContext) throws Throwable { JspWriter out = pageContext.getOut(); /* ---- html:text ---- */ org.apache.struts.taglib.html.TextTag _jspx_th_html_text_0 = (org.apache.struts.taglib.html.TextTag) _jspx_tagPool_html_text_tabindex_size_property_name_nobody.get(org.apache.struts.taglib.html.TextTag.class); _jspx_th_html_text_0.setPageContext(pageContext); _jspx_th_html_text_0.setParent(_jspx_th_html_form_0); _jspx_th_html_text_0.setName("loginform"); _jspx_th_html_text_0.setProperty("name"); _jspx_th_html_text_0.setSize("15"); _jspx_th_html_text_0.setTabindex("1"); int _jspx_eval_html_text_0 = _jspx_th_html_text_0.doStartTag(); if (_jspx_th_html_text_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) return true; _jspx_tagPool_html_text_tabindex_size_property_name_nobody.reuse(_jspx_th_html_text_0); return false; } private boolean _jspx_meth_html_text_1(javax.servlet.jsp.tagext.Tag _jspx_th_html_form_0, javax.servlet.jsp.PageContext pageContext) throws Throwable { JspWriter out = pageContext.getOut(); /* ---- html:text ---- */ org.apache.struts.taglib.html.TextTag _jspx_th_html_text_1 = (org.apache.struts.taglib.html.TextTag) _jspx_tagPool_html_text_tabindex_size_property_name_nobody.get(org.apache.struts.taglib.html.TextTag.class); _jspx_th_html_text_1.setPageContext(pageContext); _jspx_th_html_text_1.setParent(_jspx_th_html_form_0); _jspx_th_html_text_1.setName("loginform"); _jspx_th_html_text_1.setProperty("password"); _jspx_th_html_text_1.setSize("15"); _jspx_th_html_text_1.setTabindex("2"); int _jspx_eval_html_text_1 = _jspx_th_html_text_1.doStartTag(); if (_jspx_th_html_text_1.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) return true; _jspx_tagPool_html_text_tabindex_size_property_name_nobody.reuse(_jspx_th_html_text_1); return false; } private boolean _jspx_meth_html_image_0(javax.servlet.jsp.tagext.Tag _jspx_th_html_form_0, javax.servlet.jsp.PageContext pageContext) throws Throwable { JspWriter out = pageContext.getOut(); /* ---- html:image ---- */ org.apache.struts.taglib.html.ImageTag _jspx_th_html_image_0 = (org.apache.struts.taglib.html.ImageTag) _jspx_tagPool_html_image_value_src_property_nobody.get(org.apache.struts.taglib.html.ImageTag.class); _jspx_th_html_image_0.setPageContext(pageContext); _jspx_th_html_image_0.setParent(_jspx_th_html_form_0); _jspx_th_html_image_0.setValue("Log In"); _jspx_th_html_image_0.setProperty("DIALOG-EVENT-LOGIN"); _jspx_th_html_image_0.setSrc("../embedded-images/index_19_login.gif"); int _jspx_eval_html_image_0 = _jspx_th_html_image_0.doStartTag(); if (_jspx_th_html_image_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) return true; _jspx_tagPool_html_image_value_src_property_nobody.reuse(_jspx_th_html_image_0); return false; } } --- NEW FILE: embedded_0002dchild_0002dlogout_jsp.java --- /* * Struts Dialogs, Child control sample. * This file was generated by Apache Jasper. */ package net.jspcontrols.dialogs.samples.embedded; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; import org.apache.jasper.runtime.*; public class embedded_0002dchild_0002dlogout_jsp extends HttpJspBase { private static java.util.Vector _jspx_includes; private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_html_form_action; private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_logic_messagesPresent; private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_html_messages_id; private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_bean_write_name_nobody; private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_html_image_value_src_property_nobody; public embedded_0002dchild_0002dlogout_jsp() { _jspx_tagPool_html_form_action = new org.apache.jasper.runtime.TagHandlerPool(); _jspx_tagPool_logic_messagesPresent = new org.apache.jasper.runtime.TagHandlerPool(); _jspx_tagPool_html_messages_id = new org.apache.jasper.runtime.TagHandlerPool(); _jspx_tagPool_bean_write_name_nobody = new org.apache.jasper.runtime.TagHandlerPool(); _jspx_tagPool_html_image_value_src_property_nobody = new org.apache.jasper.runtime.TagHandlerPool(); } public java.util.List getIncludes() { return _jspx_includes; } public void _jspDestroy() { _jspx_tagPool_html_form_action.release(); _jspx_tagPool_logic_messagesPresent.release(); _jspx_tagPool_html_messages_id.release(); _jspx_tagPool_bean_write_name_nobody.release(); _jspx_tagPool_html_image_value_src_property_nobody.release(); } public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspFactory _jspxFactory = null; javax.servlet.jsp.PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; try { _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/html;charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("<!--\r\n Struts Dialogs, Login Control example\r\n Author: Michael Jouravlev, 2004-2005\r\n\r\n This is \"Current User Info\" view for login embedded control\r\n-->\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n\r\n"); out.write("<table width=100% border=0 celpadding=0 cellspacing=2>\r\n "); /* ---- html:form ---- */ org.apache.struts.taglib.html.FormTag _jspx_th_html_form_0 = (org.apache.struts.taglib.html.FormTag) _jspx_tagPool_html_form_action.get(org.apache.struts.taglib.html.FormTag.class); _jspx_th_html_form_0.setPageContext(pageContext); _jspx_th_html_form_0.setParent(null); _jspx_th_html_form_0.setAction("/embeddedchild-tomcat.do"); int _jspx_eval_html_form_0 = _jspx_th_html_form_0.doStartTag(); if (_jspx_eval_html_form_0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { do { out.write("\r\n "); out.write("<!-- Standard Struts error handling -->\r\n "); /* ---- logic:messagesPresent ---- */ org.apache.struts.taglib.logic.MessagesPresentTag _jspx_th_logic_messagesPresent_0 = (org.apache.struts.taglib.logic.MessagesPresentTag) _jspx_tagPool_logic_messagesPresent.get(org.apache.struts.taglib.logic.MessagesPresentTag.class); _jspx_th_logic_messagesPresent_0.setPageContext(pageContext); _jspx_th_logic_messagesPresent_0.setParent(_jspx_th_html_form_0); int _jspx_eval_logic_messagesPresent_0 = _jspx_th_logic_messagesPresent_0.doStartTag(); if (_jspx_eval_logic_messagesPresent_0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { do { out.write("\r\n "); out.write("<tr>\r\n "); out.write("<td align=\"left\" bgcolor=\"#FF9966\">\r\n "); /* ---- html:messages ---- */ org.apache.struts.taglib.html.MessagesTag _jspx_th_html_messages_0 = (org.apache.struts.taglib.html.MessagesTag) _jspx_tagPool_html_messages_id.get(org.apache.struts.taglib.html.MessagesTag.class); _jspx_th_html_messages_0.setPageContext(pageContext); _jspx_th_html_messages_0.setParent(_jspx_th_logic_messagesPresent_0); _jspx_th_html_messages_0.setId("error"); int _jspx_eval_html_messages_0 = _jspx_th_html_messages_0.doStartTag(); if (_jspx_eval_html_messages_0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { java.lang.String error = null; if (_jspx_eval_html_messages_0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) { javax.servlet.jsp.tagext.BodyContent _bc = pageContext.pushBody(); out = _bc; _jspx_th_html_messages_0.setBodyContent(_bc); _jspx_th_html_messages_0.doInitBody(); } error = (java.lang.String) pageContext.findAttribute("error"); do { out.write("\r\n "); if (_jspx_meth_bean_write_0(_jspx_th_html_messages_0, pageContext)) return; out.write("\r\n "); int evalDoAfterBody = _jspx_th_html_messages_0.doAfterBody(); error = (java.lang.String) pageContext.findAttribute("error"); if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break; } while (true); if (_jspx_eval_html_messages_0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) out = pageContext.popBody(); } if (_jspx_th_html_messages_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) return; _jspx_tagPool_html_messages_id.reuse(_jspx_th_html_messages_0); out.write("\r\n "); out.write("</td>\r\n "); out.write("</tr>\r\n "); int evalDoAfterBody = _jspx_th_logic_messagesPresent_0.doAfterBody(); if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break; } while (true); } if (_jspx_th_logic_messagesPresent_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) return; _jspx_tagPool_logic_messagesPresent.reuse(_jspx_th_logic_messagesPresent_0); out.write("\r\n "); out.write("<tr>\r\n "); out.write("<td align=\"left\" width=\"50%\">Welcome, "); out.print( session.getAttribute("login.username") ); out.write("</td>\r\n "); out.write("</tr>\r\n "); out.write("<tr>\r\n "); out.write("<td align=\"left\"> "); out.write("</td>\r\n "); out.write("</tr>\r\n "); out.write("<tr>\r\n "); out.write("<td colspan=\"2\" align=\"left\">\r\n "); if (_jspx_meth_html_image_0(_jspx_th_html_form_0, pageContext)) return; out.write("\r\n "); out.write("</td>\r\n "); out.write("</tr>\r\n "); int evalDoAfterBody = _jspx_th_html_form_0.doAfterBody(); if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break; } while (true); } if (_jspx_th_html_form_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) return; _jspx_tagPool_html_form_action.reuse(_jspx_th_html_form_0); out.write("\r\n"); out.write("</table>\r\n"); } catch (Throwable t) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (pageContext != null) pageContext.handlePageException(t); } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext); } } private boolean _jspx_meth_bean_write_0(javax.servlet.jsp.tagext.Tag _jspx_th_html_messages_0, javax.servlet.jsp.PageContext pageContext) throws Throwable { JspWriter out = pageContext.getOut(); /* ---- bean:write ---- */ org.apache.struts.taglib.bean.WriteTag _jspx_th_bean_write_0 = (org.apache.struts.taglib.bean.WriteTag) _jspx_tagPool_bean_write_name_nobody.get(org.apache.struts.taglib.bean.WriteTag.class); _jspx_th_bean_write_0.setPageContext(pageContext); _jspx_th_bean_write_0.setParent(_jspx_th_html_messages_0); _jspx_th_bean_write_0.setName("error"); int _jspx_eval_bean_write_0 = _jspx_th_bean_write_0.doStartTag(); if (_jspx_th_bean_write_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) return true; _jspx_tagPool_bean_write_name_nobody.reuse(_jspx_th_bean_write_0); return false; } private boolean _jspx_meth_html_image_0(javax.servlet.jsp.tagext.Tag _jspx_th_html_form_0, javax.servlet.jsp.PageContext pageContext) throws Throwable { JspWriter out = pageContext.getOut(); /* ---- html:image ---- */ org.apache.struts.taglib.html.ImageTag _jspx_th_html_image_0 = (org.apache.struts.taglib.html.ImageTag) _jspx_tagPool_html_image_value_src_property_nobody.get(org.apache.struts.taglib.html.ImageTag.class); _jspx_th_html_image_0.setPageContext(pageContext); _jspx_th_html_image_0.setParent(_jspx_th_html_form_0); _jspx_th_html_image_0.setValue("Log In"); _jspx_th_html_image_0.setProperty("DIALOG-EVENT-LOGOUT"); _jspx_th_html_image_0.setSrc("../embedded-images/index_19_logout.gif"); int _jspx_eval_html_image_0 = _jspx_th_html_image_0.doStartTag(); if (_jspx_th_html_image_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) return true; _jspx_tagPool_html_image_value_src_property_nobody.reuse(_jspx_th_html_image_0); return false; } } |
From: <jm...@us...> - 2005-08-04 07:45:27
|
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/login In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20952/src/net/jspcontrols/dialogs/samples/login Added Files: LoginComponent.java LoginDialog.java LoginForm.java Log Message: --- NEW FILE: LoginComponent.java --- /* * Copyright 2004-2005 Michael Jouravlev * * 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 net.jspcontrols.dialogs.samples.login; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.util.Map; import java.util.HashMap; import net.jspcontrols.dialogs.actions.DialogConstants; /** * A simple login control */ public class LoginComponent extends LoginDialog { /** * Maps submit button names to methods */ protected Map getKeyMethodMap() { Map map = super.getKeyMethodMap(); map.put("DIALOG-EVENT-LOGOUT", "logout"); return map; } /** * Overrides login method, always reloads the control instead of navigating * to user page on success. */ public ActionForward login ( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Try to log in super.login(mapping, form, request, response); // Reload login control. return mapping.findForward(DialogConstants.DIALOG_RELOAD_KEY); } /** * Logs a user out and reloads this login control */ public ActionForward logout (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Clear error messages before updating the accounts or on init. clearMessages(request); LoginForm inputForm = (LoginForm) form; // Clean password in the input/output form bean inputForm.setPassword(null); // Remove login name from session, effectively logging out request.getSession().removeAttribute("login.username"); // Reload login control return mapping.findForward(DialogConstants.DIALOG_RELOAD_KEY); } public ActionForward getDialogView(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Mark response as non-cachable setNoCache(response); // Display page, corresponding to login state. HttpSession session = request.getSession(); if (session.getAttribute("login.username") == null) { return mapping.findForward("notloggedin"); } else { return mapping.findForward("loggedin"); } } } --- NEW FILE: LoginDialog.java --- /* * Copyright 2004-2005 Michael Jouravlev * * 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 net.jspcontrols.dialogs.samples.login; import net.jspcontrols.dialogs.actions.DialogAction; import net.jspcontrols.dialogs.actions.DialogConstants; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMessages; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.util.Map; import java.util.HashMap; /** * Sample login action, which uses DialogAction for POST/REDIRECT/GET, * and for displaying error messages. */ public class LoginDialog extends DialogAction { /** * Maps submit button names to methods */ protected Map getKeyMethodMap() { Map map = new HashMap(); map.put(getInitKey()+"-INIT", "init"); map.put("DIALOG-EVENT-LOGIN", "login"); return map; } /** * Initializes dialog */ public ActionForward init ( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { LoginForm inputForm = (LoginForm) form; inputForm.setName(null); inputForm.setPassword(null); request.getSession().removeAttribute("login.username"); return mapping.findForward(DialogConstants.DIALOG_RELOAD_KEY); } /** * Process login attempt (POST) */ public ActionForward login ( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Validate user name and password ActionMessages errors = form.validate(mapping, request); HttpSession session = request.getSession(); // Logout before logging in request.getSession().removeAttribute("login.username"); // Errors found, stick them into session and reload component if (errors != null) { saveDialogErrors(session, errors); return mapping.findForward(DialogConstants.DIALOG_RELOAD_KEY); // Logged in successfully; redirect to user's page } else { LoginForm inputForm = (LoginForm) form; session.setAttribute("login.username", inputForm.getName()); return mapping.findForward("userhome"); } } public ActionForward getDialogView(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Mark response as non-cachable setNoCache(response); // Use default view mapping: "DIALOG-VIEW" return super.getDialogView(mapping, form, request, response); } } --- NEW FILE: LoginForm.java --- /* * Copyright 2004-2005 Michael Jouravlev * * 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 net.jspcontrols.dialogs.samples.login; import org.apache.struts.action.*; import javax.servlet.http.HttpServletRequest; /** * Simple login form */ public class LoginForm extends ActionForm { private String name; public String getName() {return name;} public void setName(String name) {this.name = name;} private String password; public String getPassword() {return password;} public void setPassword(String password) {this.password = password;} // Generate the error messages in the same manner as usual, // but do not forget to turn "validate" property of the action mapping off. public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { if (!"guest".equalsIgnoreCase(name) || !"guest".equalsIgnoreCase(password)) { ActionErrors errors = new ActionErrors(); errors.add("ERROR", new ActionMessage("login.badpassword")); return errors; } else { return null; } } } |
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/crud In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20952/src/net/jspcontrols/dialogs/samples/crud Added Files: CRUDActionSample.java CRUDFormSample.java CRUDListActionSample.java ItemListActionSample.java Log Message: --- NEW FILE: CRUDActionSample.java --- package net.jspcontrols.dialogs.samples.crud; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import net.jspcontrols.dialogs.actions.crud.CRUDAction; import net.jspcontrols.dialogs.actions.crud.ICRUDForm; import net.jspcontrols.dialogs.samples.crud.business.BusinessObj; import java.util.ArrayList; /** * Created by IntelliJ IDEA. * User: Mikus * Date: Jun 28, 2005 * Time: 7:58:45 AM * To change this template use Options | File Templates. */ public class CRUDActionSample extends CRUDAction { /** * Returns an <code>ActionForward</code> instance describing the View * for current dialog state, usually a forward to a JSP page. * <p> * If you want to use the default implementation, define the View * under "DIALOG-VIEW" name in <forward> element of your action * mapping. * <p> * To use different mapping name, define the view in <forward> * element of your action mapping, and override this method to return * ActionForward object for your mapping name. * * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * * @exception java.lang.Exception if an exception occurs * @return ActionForward instance describing the View for dialog state */ public ActionForward getDialogView(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Mark response as non-cachable setNoCache(response); // Return mapping corresponding to business object state return super.getDialogView(mapping, form, request, response); } } --- NEW FILE: CRUDFormSample.java --- /* * Copyright 2004-2005 Michael Jouravlev * * 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 net.jspcontrols.dialogs.samples.crud; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; import net.jspcontrols.dialogs.actions.crud.ICRUDForm; import net.jspcontrols.dialogs.actions.crud.CRUDForm; import net.jspcontrols.dialogs.samples.crud.business.BusinessObj; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import java.util.ArrayList; import java.util.Iterator; /** * Example of CRUDAction an ICRUDForm usage. The data from this form bean * is stored to a simple business object with two values: stingvalue and numvalue. * * @author Michael Jouravlev */ public class CRUDFormSample extends CRUDForm implements ICRUDForm { /** * Key to store item list in the session */ public static final String CRUD_LIST_KEY = "crud-item-list"; /* * Page header: "New Item", "Edit Item" or "View Item". * Used on the JSP to reflect current UI mod. No setter for this property. */ private String itemHeader; public String getItemHeader() {return itemHeader;} /* * Item ID aka Primary Key; each business object is identified by a key. * Getter is used on JSP page, setter is used to to identify an existing * item, which must be edited. */ private String itemId; public String getItemId() {return itemId;} public void setItemId(String itemId) {this.itemId = itemId;} /************************************************************************** * Business data: every property of business object is exposed explicitly. **************************************************************************/ /* * Simple string value, must not be null. */ private String stringValue; public String getStringValue() {return stringValue;} public void setStringValue(String stringValue) {this.stringValue = stringValue;} /* * Simple integer value, must be over 150. */ private String intValue; public String getIntValue() {return intValue;} public void setIntValue(String intValue) {this.intValue = intValue;} /************************************************************************** * Data lifecycle **************************************************************************/ /** * Generates and returns ID for new item. * @return stringified ID, hopefully unique */ String createUnuqueId() { return (new Integer((new Double((Math.random() * 100000))). intValue())).toString(); } /** * Creates new item. This particular implementation generates item ID * (that is, database PK) right at the moment when item is generated. * <p> * Another approach is to generate item ID when item is actually * stored. In this case you would probably need a status field. * You would generate ID for items with "new" status. Items loaded * from database would have "existing" status. * @return non-empty ActionMessages object if could not create item. */ public ActionMessages crudCreate() { // Initialize new item itemId = createUnuqueId(); intValue = null; stringValue = null; itemHeader = "New Item"; // New item is ready to be edited changeCrudUIMode(ICRUDForm.CRUD_UI_MODE_CREATE); // No errors creating new item return null; } /** * Duplicates new business data from existing object. * @return non-empty ActionMessages object if could not duplicate item. */ public ActionMessages crudDuplicate() { return initLoadedItem(true, "New Item", ICRUDForm.CRUD_UI_MODE_CREATE); } /** * Loads business data from persistence layer into the action form or * into nested property of action form, and switches to edit mode. * @return non-empty ActionMessages object if could not load business item. */ public ActionMessages crudLoadForUpdate() { return initLoadedItem(false, "Edit Item", ICRUDForm.CRUD_UI_MODE_EDIT); } /** * Load business data from persistence layer into the action form or * into nested property of action form, and switches to view mode. * @return non-empty ActionMessages object if could not load business item. */ public ActionMessages crudLoadForPreview() { return initLoadedItem(false, "View Item", ICRUDForm.CRUD_UI_MODE_READONLY); } /** * Deletes business data from underlying persistent layer * @return non-empty ActionMessages object if could not delete item. */ public ActionMessages crudDelete() { // Find and delete item if found BusinessObj item = findOrDeleteItem(this.itemId, true); if (item != null) { // Deactivate CRUDAction view changeCrudUIMode(ICRUDForm.CRUD_UI_MODE_INACTIVE); // No errors loading an item return null; } else { ActionErrors errors = new ActionErrors(); errors.add("ERROR", new ActionMessage("crudData.itemnotfound", this.itemId)); return errors; } } /** * Cancels process of updating existing or new item. * @return always null */ public ActionMessages crudCancel() { // New item is ready to be edited changeCrudUIMode(ICRUDForm.CRUD_UI_MODE_INACTIVE); // No errors loading an item return null; } /** * Closes preview from of existing item. * @return always null */ public ActionMessages crudClose() { // New item is ready to be edited changeCrudUIMode(ICRUDForm.CRUD_UI_MODE_INACTIVE); // No errors loading an item return null; } /** * Stores business data in the persistence layer. * <p> * When new item is created, this particular implementation generates * item ID right away. * <p> * Another approach is to generate item ID when it is actually * stored. In this case you would need something like status field. * You would generate ID for items with "new" status. Items loaded * from database would have "existing" status. * @return non-empty ActionMessages object if could not store business data. */ public ActionMessages crudStore() { ActionErrors errors = new ActionErrors(); // Try to persist item if (ICRUDForm.CRUD_UI_MODE_EDITABLE.equals(getCrudUIMode()) || ICRUDForm.CRUD_UI_MODE_EDIT.equals(getCrudUIMode()) || ICRUDForm.CRUD_UI_MODE_CREATE.equals(getCrudUIMode())) { // Test business rules: fail persist if num value is too low if (Integer.parseInt(intValue) < 150) { // Keep UI mode, which is CRUD_UI_MODE_EDIT, no need to change // changeCrudUIMode(ICRUDForm.CRUD_UI_MODE_EDIT); errors.add("ERROR", new ActionMessage("crudData.storevaluetoolow")); return errors; // Persisting } else { int tempIntValue = 0; try { tempIntValue = Integer.parseInt(intValue); } catch (NumberFormatException e) { errors.add("ERROR", new ActionMessage("crudData.numbernotint")); return errors; } BusinessObj item = findOrDeleteItem(this.itemId, false); if (item != null) { item.setStringValue(this.stringValue); item.setIntValue(tempIntValue); } else { ArrayList items = (ArrayList) session.getAttribute(CRUD_LIST_KEY); item = new BusinessObj(itemId, stringValue, tempIntValue); items.add(item); } // New item is ready to be edited changeCrudUIMode(ICRUDForm.CRUD_UI_MODE_INACTIVE); // No errors storing item return null; } } else { errors.add("ERROR", new ActionMessage("crudData.badmode")); return errors; } } /************************************************************************** * Helpers **************************************************************************/ /** * Finds item in the "persistent storage", that is, in the list of items. * @param id id of item to look for * @return non-null item if found, or null if item not found */ private BusinessObj findOrDeleteItem(String id, boolean delete) { ArrayList items = null; if (session != null && (items = (ArrayList) session.getAttribute(CRUD_LIST_KEY)) != null) { Iterator itemIte = items.listIterator(); while(itemIte.hasNext()) { BusinessObj item = (BusinessObj) itemIte.next(); if (item.getItemId().equals(id)) { if (delete) { itemIte.remove(); // This is a lame way to signal that item was found and // deleted. Cannot return reference to deleted object. return new BusinessObj(); } else { return item; } } } } return null; } /** * Loads item from storage (in this example from the session object) * @return non-empty ActionMessages object if could not load item. */ private ActionMessages loadItem() { ActionErrors errors = new ActionErrors(); try { BusinessObj item = findOrDeleteItem(this.itemId, false); if (item != null) { intValue = Integer.toString(item.getIntValue()); stringValue = item.getStringValue(); return null; } else { errors.add("ERROR", new ActionMessage("crudData.itemnotfound", this.itemId)); return errors; } } catch (Throwable e) { errors.add("ERROR", new ActionMessage("crudData.internalstorageerror")); return errors; } } /** * Initialized loaded item for duplicate, edit and preview modes. * @param initId if true, generate new item ID * @param title page title to use, like "View item" or "Edit item" * @param successState which state to switch to if item loaded successfully * @return non-empty ActionMessages object if could not load business item. */ private ActionMessages initLoadedItem(boolean initId, String title, String successState) { // Load existing item. Use item id which is already set in the form. ActionMessages errors = loadItem(); // Loaded successfully if (errors == null || errors.isEmpty()) { if (initId) { // Create new item ID, used for duplicating itemId = createUnuqueId(); } // Set up header for view JSP page itemHeader = title; // New item is ready to be edited or viewed changeCrudUIMode(successState); // No errors loading an item return null; // Could not load } else { // Deactivate CRUDAction view changeCrudUIMode(ICRUDForm.CRUD_UI_MODE_INACTIVE); // Report errors to CRUDAction return errors; } } /************************************************************************** * Reset and Validate **************************************************************************/ /** * Session stores list of business objects in this demo */ private HttpSession session; /** * Resets action form. Clear checkboxes here. This method is called before * form fields are populated, so here you can check request type, scope * and other action form parameters. * * @param mapping The ActionMapping used to select this instance * @param request The HTTP request we are processing */ public void reset(ActionMapping mapping, HttpServletRequest request) { super.reset(mapping, request); // Store session to access business objects this.session = request.getSession(); } /** * Validates input data. This method should be called manually from * action class to ensure, that (1) fields are not validated during * rendering phase, and to ensure that (2) action class handlers are called * even if input data is invalid. * @param actionMapping * @param httpServletRequest * @return */ public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { ActionErrors errors = new ActionErrors(); if (stringValue == null || stringValue.length() == 0) { errors.add("ERROR", new ActionMessage("crudData.stringisnull")); } try { Integer.parseInt(intValue); } catch (NumberFormatException e) { errors.add("ERROR", new ActionMessage("crudData.numbernotint")); } return errors; } } --- NEW FILE: CRUDListActionSample.java --- package net.jspcontrols.dialogs.samples.crud; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import net.jspcontrols.dialogs.actions.crud.CRUDAction; import net.jspcontrols.dialogs.actions.crud.ICRUDForm; import net.jspcontrols.dialogs.samples.crud.business.BusinessObj; import java.util.ArrayList; /** * Created by IntelliJ IDEA. * User: Mikus * Date: Jun 28, 2005 * Time: 7:58:45 AM * To change this template use Options | File Templates. */ public class CRUDListActionSample extends CRUDAction { public void prepareItemList(HttpServletRequest request) { // Verify that item list exists in session HttpSession session = request.getSession(); synchronized(session) { ArrayList items = (ArrayList) session.getAttribute(CRUDFormSample.CRUD_LIST_KEY); // Create test sample of three items if (items == null) { items = new ArrayList(); items.add(new BusinessObj()); items.add(new BusinessObj()); items.add(new BusinessObj()); session.setAttribute(CRUDFormSample.CRUD_LIST_KEY, items); } } } /** * Returns an <code>ActionForward</code> instance describing the View * for current dialog state, usually a forward to a JSP page. * <p> * If you want to use the default implementation, define the View * under "DIALOG-VIEW" name in <forward> element of your action * mapping. * <p> * To use different mapping name, define the view in <forward> * element of your action mapping, and override this method to return * ActionForward object for your mapping name. * * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * * @exception Exception if an exception occurs * @return ActionForward instance describing the View for dialog state */ public ActionForward getDialogView(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Mark response as non-cachable setNoCache(response); // Obtain current BO mode ICRUDForm crudForm = (ICRUDForm) form; String uiMode = crudForm.getCrudUIMode(); // There are no active items, so show item list if (ICRUDForm.CRUD_UI_MODE_INACTIVE.equals(uiMode)) { prepareItemList(request); } // Display a page corresponding to current item state return mapping.findForward(uiMode); } } --- NEW FILE: ItemListActionSample.java --- /* * Copyright 2004-2005 Michael Jouravlev * * 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 net.jspcontrols.dialogs.samples.crud; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.util.ArrayList; import java.util.Map; import java.util.HashMap; import net.jspcontrols.dialogs.samples.crud.business.BusinessObj; /** * This class builds list of business items. This is a helper to show * CRUDAction in work. * * @author Michael Jouravlev */ public class ItemListActionSample extends Action { /** * Prepare and show item list. Each item can be operated by CRUDAction. */ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Verify that item list exists in session HttpSession session = request.getSession(); ArrayList items = (ArrayList) session.getAttribute(CRUDFormSample.CRUD_LIST_KEY); // Create default item list of three items if (items == null) { items = new ArrayList(); items.add(new BusinessObj()); items.add(new BusinessObj()); items.add(new BusinessObj()); session.setAttribute(CRUDFormSample.CRUD_LIST_KEY, items); } // Modify response header to make page non-cachable. response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-cache,no-store,max-age=0"); response.setDateHeader("Expires", 1); // Show item list in crud-list.jsp return mapping.findForward("showlist"); } } |
From: <jm...@us...> - 2005-08-04 07:45:27
|
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/crud/business In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20952/src/net/jspcontrols/dialogs/samples/crud/business Added Files: BusinessObj.java Log Message: --- NEW FILE: BusinessObj.java --- /* * Copyright 2004-2005 Michael Jouravlev * * 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 net.jspcontrols.dialogs.samples.crud.business; /** * A simple bean, represinting a Business Object. For simplicity, * no business rules are defined. This is just a struct. * * @author Michael Jouravlev */ public class BusinessObj { /* * Business Object ID, a primary key */ private String itemId; public String getItemId() {return itemId;} public void setItemId(String itemId) {this.itemId = itemId;} /* * Business object value, must be short integer */ private String stringValue; public String getStringValue() {return stringValue;} public void setStringValue(String value) {this.stringValue = value;} /* * Business object status, can be "New" or "Stored". */ private int intValue; public int getIntValue() {return intValue;} public void setIntValue(int intValue) {this.intValue = intValue;} /** * Creates new Business Object with random 4-digit ID */ public BusinessObj() { itemId = (new Integer((new Double((Math.random() * 100000))).intValue())).toString(); this.stringValue = "Item #" + itemId; this.intValue = (new Double((Math.random() * 100000))).intValue(); } /** * Creates new Business Object with a certain ID but * with random value. Used to create default items. * * @param id Business Object ID */ public BusinessObj(String id) { this.itemId = id; this.stringValue = "-default-"; this.intValue = (new Double((Math.random() * 100000))).intValue(); } /** * Creates new Business Object with particular ID, value and status * * @param id Business Object ID * @param strValue Business Object value * @param intValue Business Object status */ public BusinessObj(String id, String strValue, int intValue) { this.itemId = id; this.stringValue = strValue; this.intValue = intValue; } /** * Creates a full copy of another Business Object * * @param item Source Business Object */ public BusinessObj(BusinessObj item) { this.itemId = item.itemId; this.stringValue = item.stringValue; this.intValue = item.intValue; } } |
From: <jm...@us...> - 2005-08-04 07:44:10
|
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/wizard/signupsimple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20635/signupsimple Log Message: Directory /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/wizard/signupsimple added to the repository |
From: <jm...@us...> - 2005-08-04 07:44:10
|
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/wizard/signupfull In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20635/signupfull Log Message: Directory /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/wizard/signupfull added to the repository |
From: <jm...@us...> - 2005-08-04 07:44:10
|
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/wizard/rules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20635/rules Log Message: Directory /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/wizard/rules added to the repository |
From: <jm...@us...> - 2005-08-04 07:44:09
|
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/wizard/accounts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20635/accounts Log Message: Directory /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/wizard/accounts added to the repository |
From: <jm...@us...> - 2005-08-04 07:42:37
|
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/crud/business In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20290/business Log Message: Directory /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/crud/business added to the repository |
From: <jm...@us...> - 2005-08-04 07:42:29
|
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/login In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20219/login Log Message: Directory /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/login added to the repository |
From: <jm...@us...> - 2005-08-04 07:42:29
|
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/wizard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20219/wizard Log Message: Directory /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/wizard added to the repository |
From: <jm...@us...> - 2005-08-04 07:42:29
|
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/embedded In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20219/embedded Log Message: Directory /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/embedded added to the repository |
From: <jm...@us...> - 2005-08-04 07:42:29
|
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/crud In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20219/crud Log Message: Directory /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/samples/crud added to the repository |
From: <jm...@us...> - 2005-08-04 07:40:41
|
Update of /cvsroot/struts/dialogs/war/WEB-INF In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19672/war/WEB-INF Modified Files: struts-config.xml web.xml Log Message: Index: struts-config.xml =================================================================== RCS file: /cvsroot/struts/dialogs/war/WEB-INF/struts-config.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** struts-config.xml 11 Jul 2005 07:13:04 -0000 1.9 --- struts-config.xml 4 Aug 2005 07:39:45 -0000 1.10 *************** *** 9,74 **** <form-beans> <!-- Struts requires, that action processing POST request, must have ! corresponding form bean. This is a dummy dynabean for such cases. --> ! <form-bean name="dummyForm" type="org.apache.struts.action.DynaActionForm"/> ! <form-bean name="dialogloginform" type="net.jspcontrols.dialogs.samples.dialogloginaction.DialogLoginForm"/> ! <form-bean name="crudform" type="net.jspcontrols.dialogs.samples.crudaction.CRUDFormSample"/> ! <form-bean name="wizardform" type="net.jspcontrols.dialogs.samples.wizardaction.wizardsimple.SimpleSignupForm"/> </form-beans> <action-mappings> <!-- **************************************************************** ! SelectAction sample, an improvement over standard DispatchAction **************************************************************** --> ! <action path="/selectaction" ! type = "net.jspcontrols.dialogs.samples.selectaction.SelectActionTest" ! name = "dummyForm" ! scope = "request" ! parameter = "app-submit"> ! <forward name = "addpage" path="/selectadd.html"/> ! <forward name = "deletepage" path="/selectdelete.html"/> ! <forward name = "loginpage" path="/selectlogin.html"/> ! <forward name = "cancelpage" path="/selectcancel.html"/> ! <forward name = "unspecifiedpage" path="/selectunspecified.html"/> </action> <!-- **************************************************************** ! DialogAction sample, login page **************************************************************** --> ! <action path="/dialogloginaction" ! type = "net.jspcontrols.dialogs.samples.dialogloginaction.DialogLoginAction" ! name = "dialogloginform" scope = "session" ! validate = "false" ! parameter = "DIALOG-EVENT"> ! <!-- Where to return on error, this entry is optional. See next example. --> ! <forward name = "DIALOG-RELOAD" path="/dialogloginaction.do" redirect="true"/> ! <!-- Default view --> ! <forward name="DIALOG-VIEW" path="/dialogloginaction.jsp"/> ! <!-- Jump to other location --> ! <forward name="userhome" path="/dialogloginuserpage.jsp" redirect="true"/> </action> <!-- **************************************************************** ! DialogAction sample, stateful login web control **************************************************************** --> ! <action path="/dialogloginactioncontrol" ! type = "net.jspcontrols.dialogs.samples.dialogloginaction.DialogLoginActionControl" ! name = "dialogloginform" scope = "session" ! validate = "false" ! parameter = "DIALOG-EVENT"> ! <!-- Notice, that DIALOG-RELOAD entry is omitted. Action is automatically reloaded. --> ! <!-- Log In page --> ! <forward name="notloggedin" path="/dialogloginactioncontrol-login.jsp"/> ! <!-- Log Out page --> ! <forward name="loggedin" path="/dialogloginactioncontrol-logout.jsp"/> ! <!-- Jump to other location --> ! <forward name="userhome" path="/dialoglogincontroluserpage.jsp" redirect="true"/> </action> <!-- **************************************************************** --- 9,106 ---- <form-beans> <!-- Struts requires, that action processing POST request, must have ! corresponding action form. This is a dummy dynabean for cases when ! target action does not use an action form. ! Used in SelectAction sample and in CRUD item list page. --> ! <form-bean name = "dummyForm" type="org.apache.struts.action.DynaActionForm"/> ! <!-- Used in login dialog, login component and embedded login control --> ! <form-bean name = "loginform" type="net.jspcontrols.dialogs.samples.login.LoginForm"/> ! <!-- Used in CRUD example --> ! <form-bean name = "crudform" type="net.jspcontrols.dialogs.samples.crud.CRUDFormSample"/> ! <!-- Used in wizard example. You can choose either SignupForm or SignupFormSimple for ! same results. SignupFormSimple extends base WizardForm, thus it is in fact very simple. --> ! <!-- ! <form-bean name = "wizardform" type="net.jspcontrols.dialogs.samples.wizard.signupfull.SignupForm"/> ! --> ! <form-bean name = "wizardform" type="net.jspcontrols.dialogs.samples.wizard.signupsimple.SignupFormSimple"/> </form-beans> + <action-mappings> <!-- **************************************************************** ! SelectAction sample, an improved DispatchAction. HTML is in war/selectaction. **************************************************************** --> ! <action path = "/sample-selectaction/selectaction" ! type = "net.jspcontrols.dialogs.samples.selectaction.SelectActionSample" ! name = "dummyForm"> ! ! <forward name = "result" path = "/sample-selectaction/selectresult.jsp"/> ! <forward name = "addpage" path = "/sample-selectaction/selectadd.html"/> ! <forward name = "deletepage" path = "/sample-selectaction/selectdelete.html"/> ! <forward name = "loginpage" path = "/sample-selectaction/selectlogin.html"/> ! <forward name = "cancelpage" path = "/sample-selectaction/selectcancel.html"/> ! <forward name = "unspecifiedpage" path = "/sample-selectaction/selectunspecified.html"/> </action> <!-- **************************************************************** ! Login Dialog sample. JSP are in war/logindialog. **************************************************************** --> ! <action path = "/sample-logindialog/logindialog" ! type = "net.jspcontrols.dialogs.samples.login.LoginDialog" ! name = "loginform" scope = "session" ! validate = "false"> ! <forward name = "DIALOG-RELOAD" path = "/sample-logindialog/logindialog.do" redirect = "true"/> ! <forward name = "DIALOG-VIEW" path = "/sample-logindialog/login.jsp"/> ! <forward name = "userhome" path = "/sample-logindialog/userpage.jsp" redirect = "true"/> </action> <!-- **************************************************************** ! Login/logout component sample. JSP in war/logincomponent. **************************************************************** --> ! <action path = "/sample-logincomponent/logincomponent" ! type = "net.jspcontrols.dialogs.samples.login.LoginComponent" ! name = "loginform" scope = "session" ! validate = "false"> ! <forward name = "DIALOG-RELOAD" path = "/sample-logincomponent/logincomponent.do" redirect = "true"/> ! <forward name = "notloggedin" path = "/sample-logincomponent/logincomponent-login.jsp"/> ! <forward name = "loggedin" path = "/sample-logincomponent/logincomponent-logout.jsp"/> ! <forward name = "userhome" path = "/sample-logincomponent/userpage.jsp" redirect = "true"/> </action> + <!-- **************************************************************** + Master page + login child control for containers, which exceed + JSP specifications in terms of included resources, like Resin. + JSP in See war/logincontrol directory. + **************************************************************** --> + + <action path = "/embedded-resin" forward = "/sample-logincontrol/resin/masterpage.jsp"/> + <action path = "/embeddedchild-resin" + type = "net.jspcontrols.dialogs.samples.embedded.EmbeddedControlResin" + name = "loginform" + scope = "session" + validate = "false"> + <forward name = "DIALOG-RELOAD" path = "/embedded-resin.do" redirect = "true"/> + <forward name = "notloggedin" path = "/sample-logincontrol/resin/embedded-child-login.jsp"/> + <forward name = "loggedin" path = "/sample-logincontrol/resin/embedded-child-logout.jsp"/> + </action> + + <!-- **************************************************************** + Master page + login child control for containers, which strictly + implement JSP specifications like Tomcat. + **************************************************************** --> + + <action path = "/embedded-tomcat" forward = "/sample-logincontrol/tomcat/masterpage.jsp"/> + <action path = "/embeddedchild-tomcat" + type = "net.jspcontrols.dialogs.samples.embedded.EmbeddedControlTomcat" + name = "loginform" + scope = "session" + validate = "false"> + <forward name = "DIALOG-RELOAD" path = "/embedded-tomcat.do" redirect = "true"/> + </action> <!-- **************************************************************** *************** *** 76,167 **** **************************************************************** --> ! <!-- CRUD action helper: item list --> ! <action path="/cruditemlist" ! type = "net.jspcontrols.dialogs.samples.crudaction.ItemListActionSample" ! name = "dummyForm"> ! <forward name = "showlist" path="/crudaction-list.jsp"/> </action> <!-- CRUD action --> ! <action path="/crudaction" type = "net.jspcontrols.dialogs.actions.crud.CRUDAction" name = "crudform" scope = "session" ! validate = "false" ! parameter = "DIALOG-EVENT"> ! <forward name="MENU" path="/allsamples.html" redirect="true"/> ! <!-- Where to hand control over after input phase (POST) --> ! ! <forward name="ON-CREATE-SUCCESS" path="/crudaction.do" redirect="true"/> ! <forward name="ON-DUPLICATE-SUCCESS" path="/crudaction.do" redirect="true"/> ! ! <forward name="ON-PREVIEW" path="/crudaction.do" redirect="true"/> ! <forward name="ON-EDIT" path="/crudaction.do" redirect="true"/> ! <forward name="ON-LOAD-FAILURE" path="/erroraction.do" redirect="true"/> ! ! <forward name="ON-DELETE-SUCCESS" path="/cruditemlist.do" redirect="true"/> ! <forward name="ON-DELETE-FAILURE" path="/erroraction.do" redirect="true"/> ! ! <forward name="ON-CANCEL" path="/cruditemlist.do" redirect="true"/> ! <forward name="ON-CLOSE" path="/cruditemlist.do" redirect="true"/> ! ! <forward name="ON-STORE-SUCCESS" path="/cruditemlist.do" redirect="true"/> ! ! <forward name="ON-STORE-FAILURE" path="/crudaction.do" redirect="true"/> ! <forward name="ON-INVALID-DATA" path="/crudaction.do" redirect="true"/> <!-- Which page to load on the output phase or on refresh (GET) --> ! ! <!-- Edit Mode --> ! <forward name="CRUD-UI-MODE-EDITABLE" path="/crudaction-edit.jsp"/> <!-- Preview Mode --> ! <forward name="CRUD-UI-MODE-READONLY" path="/crudaction-noedit.jsp"/> <!-- Illegal mode, item is not active --> ! <forward name="CRUD-UI-MODE-INACTIVE" path="/crudaction-notactive.jsp"/> ! </action> ! <action path="/erroraction" forward="/crudaction-error.jsp"/> <!-- **************************************************************** CRUD action 2: create, duplucate, edit, view, delete item **************************************************************** --> <!-- CRUD action --> ! <action path="/crudactionlite" ! type = "net.jspcontrols.dialogs.samples.crudaction.CRUDActionSample" name = "crudform" scope = "session" ! validate = "false" ! parameter = "DIALOG-EVENT"> ! ! <forward name="ON-CREATE-SUCCESS" path="/crudactionlite.do" redirect="true"/> ! <forward name="ON-DUPLICATE-SUCCESS" path="/crudactionlite.do" redirect="true"/> ! ! <forward name="ON-PREVIEW" path="/crudactionlite.do" redirect="true"/> ! <forward name="ON-EDIT" path="/crudactionlite.do" redirect="true"/> ! <forward name="ON-LOAD-FAILURE" path="/crudaction-error.jsp"/> ! ! <forward name="ON-DELETE-SUCCESS" path="/crudactionlite.do" redirect="true"/> ! <forward name="ON-DELETE-FAILURE" path="/crudaction-error.jsp"/> ! ! <forward name="ON-CANCEL" path="/crudactionlite.do" redirect="true"/> ! <forward name="ON-CLOSE" path="/crudactionlite.do" redirect="true"/> ! ! <forward name="ON-STORE-SUCCESS" path="/crudactionlite.do" redirect="true"/> ! <forward name="ON-STORE-FAILURE" path="/crudactionlite.do" redirect="true"/> ! <forward name="ON-INVALID-DATA" path="/crudactionlite.do" redirect="true"/> <!-- Which page to load on the output phase or on refresh (GET) --> ! <!-- Edit Mode --> ! <forward name="CRUD-UI-MODE-EDITABLE" path="/crudaction-lite-edit.jsp"/> <!-- Preview Mode --> ! <forward name="CRUD-UI-MODE-READONLY" path="/crudaction-lite-noedit.jsp"/> <!-- If item is not active, show item list --> ! <forward name="CRUD-UI-MODE-INACTIVE" path="/crudaction-lite-list.jsp"/> </action> - <action path="/erroraction" forward="/crudaction-error.jsp"/> <!-- **************************************************************** --- 108,186 ---- **************************************************************** --> ! <!-- CRUD helper: item list --> ! <action path = "/cruditemlist" ! type = "net.jspcontrols.dialogs.samples.crud.ItemListActionSample" ! name = "dummyForm"> ! <forward name = "showlist" path = "/sample-crud/crudaction-list.jsp"/> </action> <!-- CRUD action --> ! <action path = "/crudaction" type = "net.jspcontrols.dialogs.actions.crud.CRUDAction" name = "crudform" scope = "session" ! validate = "false"> <!-- Where to hand control over after input phase (POST) --> ! <forward name = "ON-CREATE-SUCCESS" path = "/crudaction.do" redirect = "true"/> ! <forward name = "ON-DUPLICATE-SUCCESS" path = "/crudaction.do" redirect = "true"/> ! <forward name = "ON-PREVIEW" path = "/crudaction.do" redirect = "true"/> ! <forward name = "ON-EDIT" path = "/crudaction.do" redirect = "true"/> ! <forward name = "ON-LOAD-FAILURE" path = "/erroraction.do" redirect = "true"/> ! <forward name = "ON-DELETE-SUCCESS" path = "/cruditemlist.do" redirect = "true"/> ! <forward name = "ON-DELETE-FAILURE" path = "/erroraction.do" redirect = "true"/> ! <forward name = "ON-CANCEL" path = "/cruditemlist.do" redirect = "true"/> ! <forward name = "ON-CLOSE" path = "/cruditemlist.do" redirect = "true"/> ! <forward name = "ON-STORE-SUCCESS" path = "/cruditemlist.do" redirect = "true"/> ! <forward name = "ON-STORE-FAILURE" path = "/crudaction.do" redirect = "true"/> ! <forward name = "ON-INVALID-DATA" path = "/crudaction.do" redirect = "true"/> <!-- Which page to load on the output phase or on refresh (GET) --> ! <!-- Edit Existing Item --> ! <forward name = "CRUD-UI-MODE-EDIT" path = "/sample-crud/crudaction-edit.jsp"/> ! <!-- Edit Newly Created Item --> ! <forward name = "CRUD-UI-MODE-CREATE" path = "/sample-crud/crudaction-edit.jsp"/> <!-- Preview Mode --> ! <forward name = "CRUD-UI-MODE-READONLY" path = "/sample-crud/crudaction-noedit.jsp"/> <!-- Illegal mode, item is not active --> ! <forward name = "CRUD-UI-MODE-INACTIVE" path = "/sample-crud/crudaction-notactive.jsp"/> </action> ! <action path = "/erroraction" forward="/sample-crud/crudaction-error.jsp"/> <!-- **************************************************************** CRUD action 2: create, duplucate, edit, view, delete item + Both item list and item details are serviced by one action. **************************************************************** --> <!-- CRUD action --> ! <action path = "/crudactionlite" ! type = "net.jspcontrols.dialogs.samples.crud.CRUDActionSample" name = "crudform" scope = "session" ! validate = "false"> ! <forward name = "ON-CREATE-SUCCESS" path = "/crudactionlite.do" redirect = "true"/> ! <forward name = "ON-DUPLICATE-SUCCESS" path = "/crudactionlite.do" redirect = "true"/> ! <forward name = "ON-PREVIEW" path = "/crudactionlite.do" redirect = "true"/> ! <forward name = "ON-EDIT" path = "/crudactionlite.do" redirect = "true"/> ! <forward name = "ON-LOAD-FAILURE" path = "/erroraction.do"/> ! <forward name = "ON-DELETE-SUCCESS" path = "/crudactionlite.do" redirect = "true"/> ! <forward name = "ON-DELETE-FAILURE" path = "/erroraction.do"/> ! <forward name = "ON-CANCEL" path = "/crudactionlite.do" redirect = "true"/> ! <forward name = "ON-CLOSE" path = "/crudactionlite.do" redirect = "true"/> ! <forward name = "ON-STORE-SUCCESS" path = "/crudactionlite.do" redirect = "true"/> ! <forward name = "ON-STORE-FAILURE" path = "/crudactionlite.do" redirect = "true"/> ! <forward name = "ON-INVALID-DATA" path = "/crudactionlite.do" redirect = "true"/> <!-- Which page to load on the output phase or on refresh (GET) --> ! <!-- Edit Existing Item --> ! <forward name = "CRUD-UI-MODE-EDIT" path = "/sample-crud/crudaction-lite-edit.jsp"/> ! <!-- Edit Newly Created Item --> ! <forward name = "CRUD-UI-MODE-CREATE" path = "/sample-crud/crudaction-lite-edit.jsp"/> <!-- Preview Mode --> ! <forward name = "CRUD-UI-MODE-READONLY" path = "/sample-crud/crudaction-lite-noedit.jsp"/> <!-- If item is not active, show item list --> ! <forward name = "CRUD-UI-MODE-INACTIVE" path = "/sample-crud/crudaction-lite-list.jsp"/> </action> <!-- **************************************************************** *************** *** 169,174 **** **************************************************************** --> ! <action path="/wizardaction" ! type = "net.jspcontrols.dialogs.samples.wizardaction.wizardsimple.SimpleSignupAction" name = "wizardform" scope = "session" --- 188,193 ---- **************************************************************** --> ! <action path = "/wizardaction" ! type = "net.jspcontrols.dialogs.actions.wizard.WizardAction" name = "wizardform" scope = "session" *************** *** 178,258 **** <!-- Where to hand control over after input phase (POST) --> ! <forward name="MAPPING_ON_BACK_SUCCESS" path="/wizardaction.do" redirect="true"/> ! <forward name="MAPPING_ON_BACK_FAILURE" path="/wizardaction.do" redirect="true"/> ! <forward name="MAPPING_ON_NEXT_SUCCESS" path="/wizardaction.do" redirect="true"/> ! <forward name="MAPPING_ON_NEXT_FAILURE" path="/wizarderroraction.do" redirect="true"/> ! <forward name="ON-CANCEL" path="/allsamples.html" redirect="true"/> ! <forward name="ON-DONE" path="/wizard-userpage.jsp" redirect="true"/> <!-- Which page to load on the output phase or on refresh (GET) --> ! <forward name="Signup Node" path="/wizard-signupstart.jsp"/> ! <forward name="Details Node" path="/wizard-signupdetails.jsp"/> ! <forward name="Confirmation Node" path="/wizard-signupconfirm.jsp"/> ! </action> ! <action path="/wizarderroraction" forward="/wizard-error.jsp"/> ! ! ! <!-- **************************************************************** ! Master page + login child control for containers, which exceed ! JSP specifications like Resin. ! **************************************************************** --> ! <action path="/embeddedmasterpage-resin" forward="/embedded-masterpage-resin.jsp"/> ! <action path="/embeddedchild-resin" ! type = "net.jspcontrols.dialogs.samples.childaction.EmbeddedActionResin" ! name = "dialogloginform" ! scope = "session" ! validate = "false" ! parameter = "DIALOG-EVENT"> ! <!-- Where to return after input is processed --> ! <forward name = "DIALOG-RELOAD" path="/embeddedmasterpage-resin.do" redirect="true"/> ! <!-- Log In page --> ! <forward name="notloggedin" path="/embedded-child-login.jsp"/> ! <!-- Log Out page --> ! <forward name="loggedin" path="/embedded-child-logout.jsp"/> ! </action> ! ! <!-- **************************************************************** ! Master page + login child control for containers, which strictly ! implement JSP specifications like Tomcat. ! **************************************************************** --> ! ! <action path="/embeddedmasterpage-tomcat" forward="/embedded-masterpage-tomcat.jsp"/> ! <action path="/embeddedchild-tomcat" ! type = "net.jspcontrols.dialogs.samples.childaction.EmbeddedActionTomcat" ! name = "dialogloginform" ! scope = "session" ! validate = "false" ! parameter = "DIALOG-EVENT"> ! <!-- Where to return after input is processed --> ! <forward name = "DIALOG-RELOAD" path="/embeddedmasterpage-tomcat.do" redirect="true"/> ! <!-- Component is rendered by Struts action --> ! </action> ! ! ! <action path="/tabcontrol" ! type = "net.jspcontrols.collab.TabControlAction"> ! <!-- Reload phase: base path, appended with sublevels --> ! <forward name = "MAINPAGE" path="main" redirect="true"/> ! <!-- Render phase: show tabs --> ! <forward name = "TABS" path="/tabs.jsp"/> ! </action> ! ! ! <action path="/main" ! type = "net.jspcontrols.collab.MasterPageAction"> ! <forward name = "FORWARD" path="main/" redirect="true"/> </action> - <!-- - Forward action does not allow to forward or redirect to location without - leading slash. Standard action prohibits forwarding without leading slash, - but allows redirecting. - <action path="/main*" forward="main/" redirect="true"/> - --> - <action path="/main/**" forward="/mainpage.jsp"/> - - </action-mappings> --- 197,215 ---- <!-- Where to hand control over after input phase (POST) --> ! <forward name = "ON-BACK-SUCCESS" path = "/wizardaction.do" redirect = "true"/> ! <forward name = "ON-BACK-FAILURE" path = "/wizardaction.do" redirect = "true"/> ! <forward name = "ON-NEXT-SUCCESS" path = "/wizardaction.do" redirect = "true"/> ! <forward name = "ON-NEXT-FAILURE" path = "/wizardaction.do" redirect = "true"/> ! <forward name = "ON-CANCEL" path = "/index.html" redirect = "true"/> ! <forward name = "ON-DONE" path = "/sample-wizardaction/wizard-userpage.jsp" redirect = "true"/> <!-- Which page to load on the output phase or on refresh (GET) --> ! <forward name = "Signup Node" path = "/sample-wizardaction/wizard-signupstart.jsp"/> ! <forward name = "Details Node" path = "/sample-wizardaction/wizard-signupdetails.jsp"/> ! <forward name = "Confirmation Node" path = "/sample-wizardaction/wizard-signupconfirm.jsp"/> </action> </action-mappings> *************** *** 261,264 **** </struts-config> - - --- 218,219 ---- Index: web.xml =================================================================== RCS file: /cvsroot/struts/dialogs/war/WEB-INF/web.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** web.xml 11 Jul 2005 06:49:04 -0000 1.2 --- web.xml 4 Aug 2005 07:39:45 -0000 1.3 *************** *** 6,10 **** <web-app> ! <display-name>Struts Dialogs Example Application</display-name> <servlet> --- 6,10 ---- <web-app> ! <display-name>Struts Dialogs Examples</display-name> <servlet> *************** *** 16,39 **** </init-param> <init-param> ! <param-name>chainConfig</param-name> ! <param-value>/WEB-INF/chain-config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> - <!-- <servlet-mapping> <servlet-name>action</servlet-name> ! <url-pattern>/site/*</url-pattern> </servlet-mapping> - --> - <servlet-mapping> - <servlet-name>action</servlet-name> - <url-pattern>*.do</url-pattern> - </servlet-mapping> <welcome-file-list> ! <welcome-file>index.shtml</welcome-file> <welcome-file>index.htm</welcome-file> </welcome-file-list> --- 16,34 ---- </init-param> <init-param> ! <param-name>validating</param-name> ! <param-value>true</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> ! <url-pattern>*.do</url-pattern> </servlet-mapping> <welcome-file-list> ! <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> + <welcome-file>index.jsp</welcome-file> </welcome-file-list> |
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19672/src/net/jspcontrols/dialogs/actions Modified Files: DialogAction.java SelectAction.java Added Files: DialogMapping.java DialogRuleSet.java EventForward.java RenderForward.java Log Message: --- NEW FILE: DialogMapping.java --- package net.jspcontrols.dialogs.actions; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForward; import org.apache.struts.config.ForwardConfig; import java.util.Iterator; /** * Created by IntelliJ IDEA. * User: mjouravlev * Date: Jul 20, 2005 * Time: 12:06:41 PM * To change this template use Options | File Templates. */ public class DialogMapping extends ActionMapping { /** * Path to the default view, usually JSP page. */ protected String view; /** * Returns the path to the default view of a corresponding dialog. */ public String getView() { return (this.view); } /** * @param view the path to the default view of a corresponding dialog. */ public void setView(String view) { if (configured) { throw new IllegalStateException("Configuration is frozen"); } this.view = view; } /** * Return name of the form bean, if any, associated with this Action. */ public String getForm() { return super.getName(); } /** * @param name name of the form bean associated with this Action. */ public void setForm(String name) { super.setName(name); } public DialogMapping() { super.setScope("session"); super.setValidate(false); } public ActionForward reload() { return EventForward.DIALOG_RELOAD; } /** * Return the forward configuration for the specified key, if any; * otherwise return <code>null</code>. * * @param name Name of the forward configuration to return */ public ForwardConfig findForwardConfig(String name) { // Standard Struts quick search for simple event name ForwardConfig forwardConfig = (ForwardConfig) forwards.get(name); if (forwardConfig != null) { return forwardConfig; } // Slow search for multi-name; do not use for heavy-traffic sites. // Will work properly, if mappings are separated (comma, space, whatever) Iterator fwIte = forwards.keySet().iterator(); while (fwIte.hasNext()) { String key = (String) fwIte.next(); if (key.indexOf(name) > -1) { return (ForwardConfig) forwards.get(key); } } return null; } } --- NEW FILE: DialogRuleSet.java --- package net.jspcontrols.dialogs.actions; import org.apache.commons.digester.Digester; import org.apache.commons.digester.RuleSetBase; import org.apache.commons.digester.AbstractObjectCreationFactory; import org.apache.struts.config.ModuleConfig; import org.apache.struts.util.RequestUtils; import org.xml.sax.Attributes; /** * Created by IntelliJ IDEA. * User: mjouravlev * Date: Jul 20, 2005 * Time: 10:07:16 AM * To change this template use Options | File Templates. */ public class DialogRuleSet extends RuleSetBase { // RuleSetBase strutsConfigRuleSet = new ConfigRuleSet(); // // public DialogRuleSet() { // super(); // // } public void addRuleInstances(Digester digester) { digester.addObjectCreate ("struts-config/action-mappings/dialog", "net.jspcontrols.dialogs.actions.DialogMapping"); digester.addSetProperties ("struts-config/action-mappings/dialog"); digester.addSetNext ("struts-config/action-mappings/dialog", "addActionConfig", "org.apache.struts.config.ActionConfig"); digester.addSetProperty ("struts-config/action-mappings/dialog/set-property", "property", "value"); digester.addObjectCreate ("struts-config/action-mappings/dialog/exception", "org.apache.struts.config.ExceptionConfig", "className"); digester.addSetProperties ("struts-config/action-mappings/dialog/exception"); digester.addSetNext ("struts-config/action-mappings/dialog/exception", "addExceptionConfig", "org.apache.struts.config.ExceptionConfig"); digester.addSetProperty ("struts-config/action-mappings/dialog/exception/set-property", "property", "value"); // digester.addFactoryCreate // ("struts-config/action-mappings/dialog/event", // new DialogForwardFactory()); digester.addObjectCreate ("struts-config/action-mappings/dialog/event", "net.jspcontrols.dialogs.actions.EventForward"); digester.addSetProperties ("struts-config/action-mappings/dialog/event"); digester.addSetNext ("struts-config/action-mappings/dialog/event", "addForwardConfig", "net.jspcontrols.dialogs.actions.EventForward"); digester.addSetProperty ("struts-config/action-mappings/action/event/set-property", "property", "value"); digester.addObjectCreate ("struts-config/action-mappings/dialog/render", "net.jspcontrols.dialogs.actions.RenderForward"); digester.addSetProperties ("struts-config/action-mappings/dialog/render"); digester.addSetNext ("struts-config/action-mappings/dialog/render", "addForwardConfig", "net.jspcontrols.dialogs.actions.RenderForward"); digester.addSetProperty ("struts-config/action-mappings/action/render/set-property", "property", "value"); } } --- NEW FILE: EventForward.java --- package net.jspcontrols.dialogs.actions; import org.apache.struts.action.ActionForward; /** * Created by IntelliJ IDEA. * User: mjouravlev * Date: Jul 20, 2005 * Time: 11:21:22 AM * To change this template use Options | File Templates. */ public class EventForward extends ActionForward { public static final ActionForward DIALOG_RELOAD = new ActionForward(); /** * <p>Construct a new instance of an <code>ActionForward</code> * object with values, default for an event forward object: * <code>path</code> is set to null, <code>redirect</code> is * set to true.</p> * * <p>Event forward objects are intended to handle the first phase * of two-phase request processing, thus they use redirect * by default.</p> */ public EventForward() { super(null, true); } /** * <p>Construct a new instance with the specified path.</p> * * @param path Path for this instance */ public EventForward(String path) { super(path, true); } } --- NEW FILE: RenderForward.java --- package net.jspcontrols.dialogs.actions; import org.apache.struts.action.ActionForward; /** * Created by IntelliJ IDEA. * User: mjouravlev * Date: Jul 20, 2005 * Time: 11:25:46 AM * To change this template use Options | File Templates. */ public class RenderForward extends ActionForward { /** * <p>Construct a new instance of an <code>ActionForward</code> * object with values, default for an render forward object: * <code>path</code> is set to null, <code>redirect</code> is * set to false.</p> * * <p>Render forward objects are intended to handle the second phase * of two-phase request processing, thus they use server-side * forwarding by default.</p> */ public RenderForward() { super(null, false); } /** * <p>Construct a new instance with the specified path.</p> * * @param path Path for this instance */ public RenderForward(String path) { super(path, false); } } Index: DialogAction.java =================================================================== RCS file: /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/DialogAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DialogAction.java 11 Jul 2005 07:13:06 -0000 1.1 --- DialogAction.java 4 Aug 2005 07:39:43 -0000 1.2 *************** *** 95,99 **** * An initialization event is one exception from this rule, and can be * processed as either POST or GET request. Initialization event has ! * a default key, DIALOG-EVENT-INIT.</p> * * <p>After input event is processed, DialogAction redirects to itself and --- 95,99 ---- * An initialization event is one exception from this rule, and can be * processed as either POST or GET request. Initialization event has ! * a default key, DIALOG-EVENT.</p> * * <p>After input event is processed, DialogAction redirects to itself and *************** *** 138,142 **** * This is a default prefix for dialog events.</p> * ! * <p>String DIALOG-EVENT-INIT = "DIALOG-EVENT-INIT";<br> * This is a default name of initialization parameter.</p> * --- 138,142 ---- * This is a default prefix for dialog events.</p> * ! * <p>String DIALOG-EVENT = "DIALOG-EVENT";<br> * This is a default name of initialization parameter.</p> * *************** *** 195,207 **** /** - * Returns the initialization key, or initialization key prefix if - * several init keys are possible. Must start with the same prefix as - * dialog buttons. - */ - protected String getInitKey() { - return "DIALOG-EVENT-INIT"; - } - - /** * Cleans messages stored in the session. Subclasses can override * this method if error messages are stored differently, or under --- 195,198 ---- *************** *** 240,251 **** /** - * Returns suffix, used for action mapping. Default suffix is ".do" - * Needed to properly setup location for dialog reloading. - */ - protected String getActionSuffix() { - return ".do"; - } - - /** * Returns true if request is considered "input" request. By convention * dialog input is sent via POST, result page is loaded via GET. --- 231,234 ---- *************** *** 299,303 **** // an in cookie, isRequestedSessionIdFromURL() returns false, // while isRequestedSessionIdFromCookie() returns true. ! // Is it a bug or is required by spec? return request.isRequestedSessionIdFromURL() && request.isRequestedSessionIdFromCookie(); --- 282,286 ---- // an in cookie, isRequestedSessionIdFromURL() returns false, // while isRequestedSessionIdFromCookie() returns true. ! // Is this a bug or a proper response? return request.isRequestedSessionIdFromURL() && request.isRequestedSessionIdFromCookie(); *************** *** 305,338 **** /** - * Returns the method name, given a prefix and a request object. - * This is a helper method, which should not normally be redefined - * by a subclass. - * - * @param mapping The ActionMapping used to select this instance - * @param form The optional ActionForm bean for this request (if any) - * @param request The HTTP request we are processing - * @param response The HTTP response we are creating - * @param parameter The <code>ActionMapping</code> parameter's name - * Contains prefix of submit button names, or several prefixes - * separated by comma or semicolon. - * - * @return The handler method name. - */ - protected String getMethodName(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response, - String parameter) - throws Exception { - - // If event prefix is not provided in action mapping parameter, - // use default dialog prefix - if (parameter == null || parameter.length() == 0) { - parameter = DialogConstants.DIALOG_EVENT_KEY; - } - return super.getMethodName(mapping, form, request, response, parameter); - } - - /** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). --- 288,291 ---- *************** *** 377,395 **** } ! // If mapping with DialogConstants.DIALOG_RELOAD_KEY is not defined, ! // build ActionForward object and redirect to self. Works if ! // actions use default ".do" suffix. ! if (actionForward == null) { ! // Appending ".do" suffix to redirect to itself ! String mappingPath = mapping.getPath(); ! if (!mappingPath.endsWith(getActionSuffix())) { ! mappingPath += getActionSuffix(); ! } ! // Action redirect ! return new ActionForward(DialogConstants.DIALOG_RELOAD_KEY, ! mappingPath, ! true /* REDIRECT */); // Has proper redirecting location --- 330,351 ---- } ! // Handler methods usually return valid ActionForward object. ! // Null is used to signify that On the other hand, null If mapping with DialogConstants.DIALOG_RELOAD_KEY is not defined, ! // build ActionForward object and redirect to self. ! if (actionForward == null ) { ! log.info("Action " + mapping.getPath() + " returned null as forward object"); ! return null; ! } else if (actionForward == EventForward.DIALOG_RELOAD) { ! // Use reload path if defined in <dialog input=... /> ! if (mapping instanceof DialogMapping && mapping.getInput() != null) { ! return new EventForward(mapping.getInput()); ! ! // If no reload path defined in the action mapping, use real ! // address since we are redirecting through browser anyway. ! } else { ! return new EventForward(request.getServletPath()); ! } // Has proper redirecting location *************** *** 406,409 **** --- 362,366 ---- true /* REDIRECT */); } + // View is requested via GET: do not clean anything, show dialog page } else { *************** *** 436,440 **** HttpServletRequest request, HttpServletResponse response) throws Exception { ! return mapping.findForward(DialogConstants.DIALOG_VIEW_KEY); } } --- 393,404 ---- HttpServletRequest request, HttpServletResponse response) throws Exception { ! if (mapping instanceof DialogMapping) { ! String viewPath = ((DialogMapping) mapping).getView(); ! RenderForward forward = new RenderForward(); ! forward.setPath(viewPath); ! return forward; ! } else { ! return mapping.findForward(DialogConstants.DIALOG_VIEW_KEY); ! } } } Index: SelectAction.java =================================================================== RCS file: /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/SelectAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SelectAction.java 11 Jul 2005 07:13:06 -0000 1.1 --- SelectAction.java 4 Aug 2005 07:39:44 -0000 1.2 *************** *** 27,103 **** import java.util.Map; import java.util.Enumeration; - import java.util.StringTokenizer; /** ! * <p>An abstract <strong>Action</strong> that dispatches ! * an HTTP form submission event to a handler method.</p> * ! * <p>The purpose of this class is processing submission of HTML forms. ! * Unlike <nop>DispatchAction and <nop>LookupDispatchAction, which correlate ! * <code>value</code> attribute of <code>submit</code> form element with ! * handler method, this class uses <code>name</code> attribute. ! * Using <code>name</code> attribute allows to display a user-friendly caption ! * on a submit button. Also, it is possible to change button caption without ! * rebuilding the application.</p> * ! * <p>The subclass must define a map, which correlates submit button names ! * with method names, and handler methods themselves. Each method must have ! * the same signature as <code>execute</code> method. Subclass should not ! * redefine <code>execute</code> method.</p> * ! * <img border="0" align="center" src="doc-files/selectaction.gif" width="485" height="540"> * ! * <p>Using <code>name</code> attribute has a flip side: ! * during reset/populate/validate process, Struts assigns request values ! * to corresponding properties of a form bean. Thus, button keys must be named ! * differently from other request attributes. Also, the dispatch action ! * must recognize situation when no submit buttons were activated.</p> * ! * <p>Therefore, all submit buttons use a prefix in their name. ! * The prefix is specified by <code>parameter</code> property ! * of the <nop>ActionMapping. Make sure that you do not use periods ! * in the prefix and in actual button names, or Struts will try to search ! * and set the nested property and most likely will throw exception.</p> * ! * <p><strong>Example of Usage</strong></p> * ! * <p>The action should be configured in <code>struts‑config.xml</code> ! * file like this:</p> ! * <pre> ! * <action path="/test" ! * type="org.example.MyAction" ! * scope="request" ! * parameter="<b>myapp-submit</b>"/> ! * </pre> ! * <p>where: ! * <ul> ! * <li><code>org.example.MyAction</code> extends <code>SelectAction</code>; ! * <li><code>parameter</code> contains prefix of your choice for all ! * submit buttons on an HTML form. ! * </ul> ! * </p> ! * <p> ! * The names of submit elements should start from the aforementioned prefix, ! * for example: ! * </p> ! * <pre> ! * <form action="http://myhost/myapp/test.do" method="post"> ! * <input type="submit" name="<b>myapp-submit</b>-button-add" value="Add button"/> ! * <input type="submit" name="<b>myapp-submit</b>-button-delete" value="Fancy Delete button"/> ! * </form> ! * </pre> ! * <p>The subclass of <nop>SelectAction class must implement ! * <code>getKeyMethodMap</code> method, which defines mapping from button names ! * to method handlers, like this:</p> ! * <pre> * protected Map getKeyMethodMap() { * Map map = new HashMap(); ! * map.put("myapp-submit-button-add", "add"); ! * map.put("myapp-submit-button-delete", "delete"); * return map; * } ! * </pre> ! * <p>The subclass also must implement the methods themselves. For example:</p> ! * <pre> * public ActionForward add(ActionMapping mapping, * ActionForm form, --- 27,88 ---- import java.util.Map; import java.util.Enumeration; /** ! * <p>An abstract <strong>Action</strong> that dispatches a browser event ! * to a handler method. This class allows to process a form submission using ! * either regular submit button or an image button. It works with regular ! * links as well.</p> ! * <ul> ! * <li>Processes submit events (POST) or link events (GET).</li> ! * <li>Handles pushbuttons, image buttons and regular links in ! * universal fashion.</li> ! * <li>Does not use <code>parameter</code> attribute of action mapping.</li> ! * <li>Allows to set an arbitrary caption for a pushbutton.</li> ! * <li>Button caption can be easily changed at runtime.</li> ! * </ul> * ! * <p><strong>Technical details</strong></p> * ! * <p>Unlike <code>DispatchAction</code> and <code>LookupDispatchAction</code> ! * classes, which correlate <code>value</code> attribute of <code>submit</code> ! * form element with name of a handler method, this class uses <code>name</code> ! * attribute. This allows to display a user-friendly caption on a submit button ! * and to change button caption without redeployment.</p> * ! * <p>The subclass must define a map, which correlates event names with method ! * names, and handler methods themselves. Events names must be different from ! * names of action form properties. Each method must have the same signature ! * as <code>execute</code> method.</p> * ! * <p>By definition, an event is a request parameter, which starts from ! * a known prefix. The prefix is specified in <code>getInitKey</code> method ! * and can be redefined in a subclass. Default prefix is "DIALOG-EVENT".</p> * ! * <p>If you decide to redifine the event prefix, make sure that it does not ! * contain periods. Also, do not use periods for specific event names. Struts ! * may throw an exception taking the name for nested property and trying ! * to set its value.</p> * ! * <p><strong>Usage</strong></p> * ! * <p>Subclass <code>SelectAction</code>, implement <code>getKeyMethodMap</code> ! * method, and map specific events to method handlers. Event name must start ! * with event prefix:</p> ! * <pre><code> * protected Map getKeyMethodMap() { * Map map = new HashMap(); ! * map.put(getInitKey()+"-ADD", "add"); ! * map.put(getInitKey()+"-DELETE", "delete"); ! * map.put(getInitKey()+"-CREATE", "create"); ! * map.put(getInitKey()+"-LOGIN", "login"); * return map; * } ! * </code></pre> ! * <p>Remember that standard <code><html:cancel/></code> button is implicitly ! * mapped to <code>cancelled</code> method. You need to implement this method ! * to receive cancel events.</p> ! * ! * <p>Implement handler methods themselves, for example:</p> ! * <pre><code> * public ActionForward add(ActionMapping mapping, * ActionForm form, *************** *** 108,137 **** * return mapping.findForward("success"); * } * ! * public ActionForward delete(ActionMapping mapping, ! * ActionForm form, ! * HttpServletRequest request, ! * HttpServletResponse response) ! * throws IOException, ServletException { ! * // do delete ! * return mapping.findForward("success"); ! * }</pre> ! * <p> ! * <strong>Notes</strong> * <ul> ! * <li>Subclass should not redefine <code>execute</code> method. * <li>If duplicate values exist for the keys returned by * <code>getKeyMethodMap</code>, the first one will be returned. ! * If no corresponding key is found then an exception will be thrown. ! * <li>Cancel button must be handled by implementing standard ! * <code>cancelled</code> method. * <li>According to HTML specification, at most one submit element is sent * from browser to the server when form is submitted. If form is submitted * without explicitly clicking a button, the result depends on a browser. * Either no buttons are submitted, or the first button defined on the form ! * is submitted. You need to override <code>unspecified</code> method ! * to handle default submits. * </ul> - * </p> * * @author Michael Jouravlev --- 93,123 ---- * return mapping.findForward("success"); * } + * </code></pre> * ! * <p>Use event names in <code>name</code> attribute of submit buttons, or ! * as query paramter for regular links:</p> ! * <pre><code> ! * <form action="/selecttest.do" method="post"> ! * <input type="submit" name="<b>DIALOG-EVENT</b>-ADD" value="Add item"/> ! * <input type="submit" name="<b>DIALOG-EVENT</b>-DELETE" value="Delete item"/> ! * </form> ! * <input type="image" name="<b>DIALOG-EVENT</b>-LOGIN" src="login.gif" value="Log In"> ! * <a href="/selecttest.do?<b>DIALOG-EVENT</b>-CREATE">Create item</a> ! * </code></pre> ! * ! * <p><strong>Notes</strong></p> * <ul> ! * <li>Subclass does not have to overridere <code>execute</code> method. * <li>If duplicate values exist for the keys returned by * <code>getKeyMethodMap</code>, the first one will be returned. ! * If no corresponding key is found then an exception will be thrown.</li> ! * <li>Standard Cancel button must be handled by <code>cancelled</code> method.</li> * <li>According to HTML specification, at most one submit element is sent * from browser to the server when form is submitted. If form is submitted * without explicitly clicking a button, the result depends on a browser. * Either no buttons are submitted, or the first button defined on the form ! * is submitted. If no butons is submitted, <code>unspecified</code> method ! * is called. Override this method to handle default submits.</li> * </ul> * * @author Michael Jouravlev *************** *** 140,151 **** /** ! * Request-key-to-method-name map */ protected Map keyMethodMap = null; /** ! * Builds a request param / method name map. Called only once for ! * each instance of this class. This is a helper method, which ! * should not normally be redefined by a subclass. */ synchronized protected void buildLookupMap() throws ServletException { --- 126,136 ---- /** ! * Map, which correlates events with handler methods */ protected Map keyMethodMap = null; /** ! * Builds an event map. Called only once for each instance of this class. ! * This internal method should not normally be redefined by a subclass. */ synchronized protected void buildLookupMap() throws ServletException { *************** *** 154,158 **** Map keyMethodMap = getKeyMethodMap(); if (keyMethodMap != null) { ! this.keyMethodMap = getKeyMethodMap(); } else { // key/method map is not defined in a subclass --- 139,143 ---- Map keyMethodMap = getKeyMethodMap(); if (keyMethodMap != null) { ! this.keyMethodMap = keyMethodMap; } else { // key/method map is not defined in a subclass *************** *** 175,181 **** /** ! * Returns the method name, given a prefix and a request object. ! * This is a helper method, which should not normally be redefined ! * by a subclass. * * @param mapping The ActionMapping used to select this instance --- 160,189 ---- /** ! * Returns the event prefix. All event names must start with this prefix. ! * Override this method if you want to use prefix different than ! * "DIALOG-EVENT" ! */ ! public String getInitKey() { ! return "DIALOG-EVENT"; ! } ! ! /** ! * Name of request parameter, identifying default event. Used to select ! * a request handler for "default submit" by Internet Explorer. If this ! * parameter is not set in request, then <code>unspecified</code> ! * method is called. ! */ ! public String getDefaultKey() { ! return "DIALOG-DEFAULT-EVENT"; ! } ! ! /** ! * Process the specified HTTP request, and create the corresponding HTTP ! * response (or forward to another web component that will create it). ! * Return an <code>ActionForward</code> instance describing where and how ! * control should be forwarded, or <code>null</code> if the response has ! * already been completed. ! * <p> ! * This method should not normally be redefined by a subclass. * * @param mapping The ActionMapping used to select this instance *************** *** 183,189 **** * @param request The HTTP request we are processing * @param response The HTTP response we are creating ! * @param parameter The <code>ActionMapping</code> parameter's name ! * Contains prefix of submit button names, or several prefixes ! * separated by comma or semicolon. * * @return The handler method name. --- 191,237 ---- * @param request The HTTP request we are processing * @param response The HTTP response we are creating ! * ! * @exception Exception if an exception occurs ! */ ! public ActionForward execute(ActionMapping mapping, ! ActionForm form, ! HttpServletRequest request, ! HttpServletResponse response) ! throws Exception { ! if (isCancelled(request)) { ! ActionForward af = cancelled(mapping, form, request, response); ! if (af != null) { ! return af; ! } ! } ! // Identify the request parameter containing the method name ! String parameter = mapping.getParameter(); ! ! // Get the method's name. This could be overridden in subclasses. ! String name = getMethodName(mapping, form, request, response, parameter); ! ! // Prevent recursive calls ! if ("execute".equals(name) || "perform".equals(name)){ ! String message = messages.getMessage("dispatch.recursive", mapping.getPath()); ! ! log.error(message); ! throw new ServletException(message); ! } ! ! // Invoke the named method, and return the result ! return dispatchMethod(mapping, form, request, response, name); ! ! } ! ! /** ! * Returns the method name, given a request object and event name. ! * This helper method should not normally be redefined by a subclass. ! * ! * @param mapping The ActionMapping used to select this instance ! * @param form The optional ActionForm bean for this request (if any) ! * @param request The HTTP request we are processing ! * @param response The HTTP response we are creating ! * @param parameter The <code>ActionMapping</code> parameter's name; ! * not used by <code>SelectAction</code> * * @return The handler method name. *************** *** 196,274 **** throws Exception { ! // Find request parameter, starting with prefix. For example, ! // "myapp-submit-button-add" parameter fits "myapp-submit" prefix . String keyName = null; Enumeration reqEn = request.getParameterNames(); - outmost: while(reqEn.hasMoreElements()) { String reqName = (String) reqEn.nextElement(); ! StringTokenizer params = new StringTokenizer(parameter, ",; "); ! while (params.hasMoreTokens()) { ! String buttonPrefix = params.nextToken(); ! if (reqName.startsWith(buttonPrefix)) { keyName = reqName; - // If using image button, strip coordinates - int imageButtonXPos = keyName.indexOf(".x"); - if (imageButtonXPos > 0) { - keyName = keyName.substring(0, imageButtonXPos); - } else { - int imageButtonYPos = keyName.indexOf(".y"); - if (imageButtonYPos > 0) { - keyName = keyName.substring(0, imageButtonYPos); - } - } - // For image button there can be two or even three parameters: - // MSIE: name.x=xcoord&name.y=ycoord - // Firefox: name.x=xcoord&name.y=ycoord&name=value - // - // We will use only one parameter. Also notice, that MSIE - // does not pass value of image button. This is another - // good reason for using "name" attribute for dispatching. - break outmost; } } } ! // If button is not be recognized, method will return null. ! // DispatchAction will call "unspecified" method. ! String methodName = null; ! // Button recognized ! if (keyName != null) { ! // Build param name to method map if it is not built yet ! buildLookupMap(); ! // Pull out a method name for request parameter ! Object mappedObj = keyMethodMap.get(keyName); ! if (mappedObj == null || !(mappedObj instanceof String)) { ! // Uncomment this, if this action is included in ! // official Struts bundle; make sure that ! // LocationStrings.properties contains ! // dispatch.keyMethodMap.notstring key ! // String message = messages.getMessage( ! // "dispatch.keyMethodMap.notstring", ! // mapping.getPath(), keyName); ! // Delete this if action is included in Struts bundle ! String message = "Dispatch action " + mapping.getPath() + ! " returned null or non-string method name" + ! " for request key " + keyName; ! throw new ServletException(message); ! } ! methodName = (String) mappedObj; ! return methodName; } ! return methodName; } /** ! * Method which is dispatched to when corresponding handler method ! * is not found for an activated submit button. Subclass should ! * override this method if it wish to provide default behavior different ! * than throwing a ServletException. */ protected ActionForward unspecified(ActionMapping mapping, --- 244,319 ---- throws Exception { ! // "parameter" is not required now; can use standard prefix or ! // redefine it with getInitKey() method ! String buttonPrefix = parameter != null ? parameter : getInitKey(); ! ! // If "parameter" attribute was not defined, look for request key ! // starting from event prefix. Standard event prefix is "DIALOG-EVENT", ! // returned by getInitKey() method. String keyName = null; Enumeration reqEn = request.getParameterNames(); while(reqEn.hasMoreElements()) { String reqName = (String) reqEn.nextElement(); ! if (reqName.startsWith(buttonPrefix)) { ! // If using image button, strip coordinate labels. ! // There can be two or even three parameters for an image button: ! // MSIE: name.x=xcoord&name.y=ycoord ! // Firefox: name.x=xcoord&name.y=ycoord&name=value ! // ! // We will use only one parameter. Also notice, that MSIE ! // does not pass "clean" value of image button. This is another ! // good reason for using "name" attribute for dispatching. ! if (reqName.endsWith(".x") || reqName.endsWith(".y")) { ! keyName = reqName.substring(0, reqName.length() - 2); ! } else { keyName = reqName; } + break; } } ! // Event not recognized, check if it was a default submit. ! if (keyName == null) { ! keyName = request.getParameter(getDefaultKey()); ! } ! // Event not recognized, DispatchAction will call "unspecified" method. ! if (keyName == null) { ! return null; ! } ! // Build param name to method map if it is not built yet ! buildLookupMap(); ! // Pull out a method name for request parameter ! Object mappedObj = keyMethodMap.get(keyName); ! if (mappedObj == null || !(mappedObj instanceof String)) { ! // Uncomment this, if this action is included in ! // official Struts bundle; make sure that ! // LocationStrings.properties contains ! // dispatch.keyMethodMap.notstring key ! // String message = messages.getMessage( ! // "dispatch.keyMethodMap.notstring", ! // mapping.getPath(), keyName); ! // Delete this if action is included in Struts bundle ! String message = "Dispatch action " + mapping.getPath() + ! " returned null or non-string method name" + ! " for request key " + keyName; ! throw new ServletException(message); } ! // Method found ! return (String) mappedObj; } /** ! * A handler method for "default submit" situation, that is when ! * an event is not recognized in a request. Default implementation ! * of this method throws a ServletException. ! * <p> ! * Override this method to provide different behavior. */ protected ActionForward unspecified(ActionMapping mapping, *************** *** 284,303 **** /** ! * Provides the mapping from the <code>name</code> attribute of ! * a submit button to method name. For example: ! * <br><pre> ! * protected Map getKeyMethodMap() { ! * Map map = new HashMap(); ! * map.put("myapp-submit-button-add", "add"); ! * map.put("myapp-submit-button-delete", "delete"); ! * return map; ! * }</pre> ! * This method is must be implemented in a subclass. * ! * @return Map, containing association between submit button name and ! * a handler method. Map keys must start from a prefix, ! * defined in <code>parameter</code> property of the action mapping. Map ! * values must contain names of handler methods. Each handler method must ! * have the same signature as <code>execute</code> method. */ protected abstract Map getKeyMethodMap(); --- 329,341 ---- /** ! * Provides mapping between event names (keys) and handler methods (values). ! * Do not forget to define handler methods themselves. Each handler method ! * must have the same signature as <code>execute</code> method. To handle ! * <code><html:cancel/></code> override <code>cancelled</code> method. ! * <p> ! * This method must be implemented by a subclass. * ! * @return Map, containing association between event names (keys) and ! * handler methods (values). */ protected abstract Map getKeyMethodMap(); |
From: <jm...@us...> - 2005-08-04 07:40:23
|
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/wizard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19672/src/net/jspcontrols/dialogs/actions/wizard Modified Files: WizardAction.java Log Message: Index: WizardAction.java =================================================================== RCS file: /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/wizard/WizardAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WizardAction.java 11 Jul 2005 07:13:12 -0000 1.1 --- WizardAction.java 4 Aug 2005 07:39:44 -0000 1.2 *************** *** 45,63 **** /** - * Returns the initialization key or initialization prefix. - * Must start with the same prefix as dialog buttons. For example, - * if dialog buttons start with "DIALOG-EVENT", then "DIALOG-EVENT-INIT" - * is a good name for initilization key, while "DIALOG-INIT" is not. - */ - protected String getInitKey() { - return "DIALOG-EVENT-INIT"; - } - - /** * Maps submit button names to handler methods; also maps initialization * keys to initialization methods. Events, external to CRUDAction, * are considered initializing events, and therefore must start with * initialization prefix. For example, if initialization prefix ! * starts with "DIALOG-EVENT-INIT", then "DIALOG-EVENT-INIT-CREATE" * is a good key for "Create new business object" event, while * "DIALOG-EVENT-CREATE" is not. --- 45,53 ---- /** * Maps submit button names to handler methods; also maps initialization * keys to initialization methods. Events, external to CRUDAction, * are considered initializing events, and therefore must start with * initialization prefix. For example, if initialization prefix ! * starts with "DIALOG-EVENT", then "DIALOG-EVENT-CREATE" * is a good key for "Create new business object" event, while * "DIALOG-EVENT-CREATE" is not. *************** *** 72,80 **** // Cancel viewing or editing of current item ! map.put("DIALOG-EVENT-CANCEL", "onCancel"); // Persist changes of current item ! map.put("DIALOG-EVENT-BACK", "onBack"); // Close preview mode of existing item ! map.put("DIALOG-EVENT-NEXT", "onNext"); return map; --- 62,70 ---- // Cancel viewing or editing of current item ! map.put(getInitKey() + "-CANCEL", "onCancel"); // Persist changes of current item ! map.put(getInitKey() + "-BACK", "onBack"); // Close preview mode of existing item ! map.put(getInitKey() + "-NEXT", "onNext"); return map; *************** *** 163,166 **** --- 153,158 ---- HttpServletRequest request, HttpServletResponse response) throws Exception { + // Make wizard pages non-cachable + setNoCache(response); // CRUDAction works with form beans, implementing ICRUDForm |
From: <jm...@us...> - 2005-08-04 07:40:23
|
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/crud In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19672/src/net/jspcontrols/dialogs/actions/crud Modified Files: CRUDAction.java CRUDForm.java ICRUDForm.java Log Message: Index: CRUDAction.java =================================================================== RCS file: /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/crud/CRUDAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CRUDAction.java 11 Jul 2005 07:13:09 -0000 1.1 --- CRUDAction.java 4 Aug 2005 07:39:44 -0000 1.2 *************** *** 87,105 **** /** - * Returns the initialization key or initialization prefix. - * Must start with the same prefix as dialog buttons. For example, - * if dialog buttons start with "DIALOG-EVENT", then "DIALOG-EVENT-INIT" - * is a good name for initilization key, while "DIALOG-INIT" is not. - */ - protected String getInitKey() { - return "DIALOG-EVENT-INIT"; - } - - /** * Maps submit button names to handler methods; also maps initialization * keys to initialization methods. Events, external to CRUDAction, * are considered initializing events, and therefore must start with * initialization prefix. For example, if initialization prefix ! * starts with "DIALOG-EVENT-INIT", then "DIALOG-EVENT-INIT-CREATE" * is a good key for "Create new business object" event, while * "DIALOG-EVENT-CREATE" is not. --- 87,95 ---- /** * Maps submit button names to handler methods; also maps initialization * keys to initialization methods. Events, external to CRUDAction, * are considered initializing events, and therefore must start with * initialization prefix. For example, if initialization prefix ! * starts with "DIALOG-EVENT", then "DIALOG-EVENT-CREATE" * is a good key for "Create new business object" event, while * "DIALOG-EVENT-CREATE" is not. Index: CRUDForm.java =================================================================== RCS file: /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/crud/CRUDForm.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CRUDForm.java 11 Jul 2005 07:13:12 -0000 1.1 --- CRUDForm.java 4 Aug 2005 07:39:44 -0000 1.2 *************** *** 43,47 **** * Returns current UT mode * @see ICRUDForm#CRUD_UI_MODE_INACTIVE - * @see ICRUDForm#CRUD_UI_MODE_EDITABLE * @see ICRUDForm#CRUD_UI_MODE_READONLY */ --- 43,46 ---- *************** *** 51,55 **** * Sets current UT mode, used by business logic code. * @see ICRUDForm#CRUD_UI_MODE_INACTIVE - * @see ICRUDForm#CRUD_UI_MODE_EDITABLE * @see ICRUDForm#CRUD_UI_MODE_READONLY */ --- 50,53 ---- *************** *** 58,61 **** --- 56,63 ---- } + public String getCRUDUIMode() { + return this.uiMode; + } + /** * Constructs CRUD form. UI Mode must be set to CRUD_UI_MODE_INACTIVE, Index: ICRUDForm.java =================================================================== RCS file: /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/crud/ICRUDForm.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ICRUDForm.java 11 Jul 2005 07:13:12 -0000 1.1 --- ICRUDForm.java 4 Aug 2005 07:39:44 -0000 1.2 *************** *** 54,57 **** --- 54,62 ---- public static final String CRUD_UI_MODE_EDITABLE = "CRUD-UI-MODE-EDITABLE"; + + public static final String CRUD_UI_MODE_EDIT = "CRUD-UI-MODE-EDIT"; + + public static final String CRUD_UI_MODE_CREATE = "CRUD-UI-MODE-CREATE"; + /** * View-only UI mode: business data must have been already created *************** *** 80,84 **** * @param mode UI mode for this action form * @see ICRUDForm#CRUD_UI_MODE_INACTIVE - * @see ICRUDForm#CRUD_UI_MODE_EDITABLE * @see ICRUDForm#CRUD_UI_MODE_READONLY */ --- 85,88 ---- *************** *** 88,92 **** * Returns current UI mode for this action form. * @see ICRUDForm#CRUD_UI_MODE_INACTIVE - * @see ICRUDForm#CRUD_UI_MODE_EDITABLE * @see ICRUDForm#CRUD_UI_MODE_READONLY */ --- 92,95 ---- |
From: <jm...@us...> - 2005-08-04 07:40:22
|
Update of /cvsroot/struts/dialogs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19672 Modified Files: readme.txt Log Message: Index: readme.txt =================================================================== RCS file: /cvsroot/struts/dialogs/readme.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** readme.txt 11 Jul 2005 06:49:04 -0000 1.5 --- readme.txt 4 Aug 2005 07:39:42 -0000 1.6 *************** *** 14,18 **** * limitations under the License. * ! * @version 1.2 */ --- 14,18 ---- * limitations under the License. * ! * @version 1.21 */ *************** *** 25,28 **** --- 25,36 ---- double submit issues or annoying POSTDATA messages. + Using precompiledStruts Dialogs and Easy Wizard + ----------------------------------------------- + If you do not want to compile source code, just drop the following jar files + into your WEB-INF/lib directory: + dialogs-rt.jar - Struts Dialogs (without samples) + ezwizard-rt.jar - Rule Engine portion of Easy Wizard. Wizard Manager is + provided by Struts Dialogs. + Building Struts Dialogs ----------------------- *************** *** 48,67 **** Changelist ---------- ! 1.2 - Added saveDialogErrors() to DialogAction, which stores error messages ! in the session in the same manner as saveErrors(HttpSession, ActionMessages) ! does starting from Struts 1.2.6 ! - Added setNoCache() to DialogAction to mark response as non-cachable. ! This allows not to set <controller nocache="true"/> global property, ! and instead use per-dialog setting. ! - New! Added example of Struts/JSP web control. Compare with Tiles and portlets. ! - New! Added WizardAction to develop rubust web wizards. Using technology ! from Easy Wizard project. ! 1.1 - SelectAction and its subclasses now support image buttons ! - New! Added CRUDAction to support create, duplicate, edit, view ! and delete operations in one single action class. ! - Improved compatibility with older versions of Struts: ! now supporting Struts 1.2.2+ ! 1.0 - first release \ No newline at end of file --- 56,84 ---- Changelist ---------- + 1.22 - SelectAction now defines getInitKey() method, which returns default event + prefix. No need to use "parameter" attribute of action mapping anymore. + - samples are repackaged ! 1.21 - Better now then later: package structure is changed. Both Easy Wizard ! and Struts Dialogs now belong to net.jspcontrols.* domain. ! - Added some comments here and there. ! - WizardAction is described at Struts Dialogs home page: ! http://struts.sourceforge.net/strutsdialogs/wizardaction.html ! 1.2 - Added saveDialogErrors() to DialogAction, which stores error messages ! in the session in the same manner as saveErrors(HttpSession, ActionMessages) ! does starting from Struts 1.2.6 ! - Added setNoCache() to DialogAction to mark response as non-cachable. ! This allows not to set <controller nocache="true"/> global property, ! and instead use per-dialog setting. ! - New! Added example of Struts/JSP web control. Compare with Tiles and portlets. ! - New! Added WizardAction to develop rubust web wizards. Using technology ! from Easy Wizard project. ! 1.1 - SelectAction and its subclasses now support image buttons ! - New! Added CRUDAction to support create, duplicate, edit, view ! and delete operations in one single action class. ! - Improved compatibility with older versions of Struts: ! now supporting Struts 1.2.2+ ! ! 1.0 - first release |
Update of /cvsroot/struts/dialogs/war/sample-wizardaction In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19672/war/sample-wizardaction Added Files: wizard-error.jsp wizard-signupconfirm.jsp wizard-signupdetails.jsp wizard-signupstart.jsp wizard-userpage.jsp Log Message: --- NEW FILE: wizard-error.jsp --- <!-- Struts Dialogs Example Author: Michael Jouravlev, 2004-2005 --> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <html:html> <head> <title>Login error</title> </head> <body> <h2>Login error</h2> </body> </html:html> --- NEW FILE: wizard-signupconfirm.jsp --- <!-- Easy Wizard example Author: Michael Jouravlev, 2004-2005 --> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <html:html locale="true"> <head> <title>New user signup: Confirmation</title> </head> <body> <!-- Standard Struts error handling --> <logic:messagesPresent> <ul> <html:messages id="error"> <li><bean:write name="error"/></li> </html:messages> </ul> </logic:messagesPresent> <!-- Show item and allow to modify it using a FORM --> <html:form action="/wizardaction.do"> <table border="1" width="400"> <tr> <td colspan="2" align="left" bgcolor="99FF66"> New user signup: Confirmation</td> </tr> <tr> <td align="left" bgcolor="99FF66"> Chosen user name:</td> <td> <bean:write name="wizardform" property="signupWizard.stepSignup.name"/></td> </tr> <tr> <td align="left" bgcolor="99FF66"> Security question:</td> <td> <bean:write name="wizardform" property="signupWizard.stepDetails.securityQuestion"/></td> </tr> <tr> <td align="left" bgcolor="99FF66"> Answer:</td> <td> <bean:write name="wizardform" property="signupWizard.stepDetails.securityAnswer"/></td> </tr> <tr> <td colspan="2" align="right" bgcolor="99FF66"> <INPUT type="submit" size="10" name="DIALOG-EVENT-CANCEL" value="Cancel"> <INPUT type="submit" size="10" name="DIALOG-EVENT-BACK" value="Back"> <INPUT type="submit" size="10" name="DIALOG-EVENT-NEXT" value="Done"> </td> </tr> </table> </html:form> </body> </html:html> --- NEW FILE: wizard-signupdetails.jsp --- <!-- Easy Wizard example Author: Michael Jouravlev, 2004-2005 --> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <html:html locale="true"> <head> <title>New user signup: Security question</title> </head> <body> <!-- Standard Struts error handling --> <logic:messagesPresent> <ul> <html:messages id="error"> <li><bean:write name="error"/></li> </html:messages> </ul> </logic:messagesPresent> <html:form action="/wizardaction.do"> <table border="1" width="400"> <tr> <td colspan="2" align="left" bgcolor="99FF66"> New user signup: Security question</td> </tr> <tr> <td align="left" bgcolor="99FF66"> Question:</td> <td> <html:select name="wizardform" property="signupWizard.stepDetails.securityAnswerId" > <html:options collection="simple-signup-questions" property="value" labelProperty="label" /> </html:select> </td> </tr> <tr> <td align="left" bgcolor="99FF66"> Your answer:</td> <td><html:text name="wizardform" property="signupWizard.stepDetails.securityAnswer" size="20" maxlength="40" tabindex="1"/> </td> </tr> <tr> <td colspan="2" align="right" bgcolor="99FF66"> <INPUT type="submit" size="10" name="DIALOG-EVENT-CANCEL" value="Cancel"> <INPUT type="submit" size="10" name="DIALOG-EVENT-BACK" value="Back"> <INPUT type="submit" size="10" name="DIALOG-EVENT-NEXT" value="Next"> </td> </tr> </table> </html:form> </body> </html:html> --- NEW FILE: wizard-signupstart.jsp --- <!-- Easy Wizard example Author: Michael Jouravlev, 2004-2005 --> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <html:html> <head> <title>New user signup: Identification</title> </head> <body> <!-- Standard Struts error handling --> <logic:messagesPresent> <ul> <html:messages id="error"> <li><bean:write name="error"/></li> </html:messages> </ul> </logic:messagesPresent> <html:form action="/wizardaction.do"> <table border="1" width="400"> <tr> <td colspan="2" align="left" bgcolor="99FF66"> New user signup: Identification</td> </tr> <tr> <td align="left" bgcolor="99FF66"> User name:</td> <td> <html:text name="wizardform" property="signupWizard.stepSignup.name" size="15" tabindex="1"/></td> </tr> <tr> <td align="left" bgcolor="99FF66"> Password:</td> <td> <html:text name="wizardform" property="signupWizard.stepSignup.password" size="15" tabindex="1"/></td> </tr> <tr> <td align="left" bgcolor="99FF66"> Retype password:</td> <td> <html:text name="wizardform" property="signupWizard.stepSignup.confirmPassword" size="15" tabindex="1"/></td> </tr> <tr> <td align="left" bgcolor="99FF66"> Security question:</td> <td><html:checkbox name="wizardform" property="signupWizard.stepSignup.personalize"/></td> </tr> <tr> <td colspan="2" align="right" bgcolor="99FF66"> <INPUT type="submit" size="10" name="DIALOG-EVENT-CANCEL" value="Cancel"> <INPUT type="submit" size="10" name="DIALOG-EVENT-NEXT" value="Next"> </td> </tr> </table> </html:form> </body> </html:html> --- NEW FILE: wizard-userpage.jsp --- <!-- Easy Wizard example Author: Michael Jouravlev, 2004-2005 --> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <% if (session.getAttribute("login.username") == null) { response.sendRedirect("wizarderroraction.do"); } %> <html:html locale="true"> <head> <title>User home page</title> </head> <body> <!-- Show boilerplate user page --> <table border="1" width="400"> <tr> <td align="left" bgcolor="#FFCC66">Welcome, <%= session.getAttribute("login.username") %>!</td> </tr> <tr> <td align="left" bgcolor="#FFCC66"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</td> </tr> </table> <p>Use Back browser button to return to previous page.</p> </body> </html:html> |
From: <jm...@us...> - 2005-08-04 07:40:10
|
Update of /cvsroot/struts/dialogs/war/sample-logincontrol/tomcat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19672/war/sample-logincontrol/tomcat Added Files: masterpage.jsp Log Message: --- NEW FILE: masterpage.jsp --- <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <html:html locale="true"> <HEAD> <html:base/> <TITLE>Your Company Name</TITLE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <!-- ImageReady Preload Script (index.psd) --> <SCRIPT TYPE="text/javascript"> <!-- function newImage(arg) { if (document.images) { rslt = new Image(); rslt.src = arg; return rslt; } } function changeImages() { if (document.images && (preloadFlag == true)) { for (var i=0; i<changeImages.arguments.length; i+=2) { document[changeImages.arguments[i]].src = changeImages.arguments[i+1]; } } } var preloadFlag = false; function preloadImages() { if (document.images) { Home_over = newImage("../embedded-images/Home-over.gif"); Company_over = newImage("../embedded-images/Company-over.gif"); Products_over = newImage("../embedded-images/Products-over.gif"); Careers_over = newImage("../embedded-images/Careers-over.gif"); Info_over = newImage("../embedded-images/Info-over.gif"); Contact_Us_over = newImage("../embedded-images/Contact-Us-over.gif"); preloadFlag = true; } } // --> </SCRIPT> <!-- End Preload Script --> </HEAD> <link href="../embedded-css/styles.css" rel="stylesheet" type="text/css"> <BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 ONLOAD="preloadImages();"><center> <!-- ImageReady Slices (index.psd) --> <TABLE WIDTH=775 BORDER=0 CELLPADDING=0 CELLSPACING=0> <!--DWLayoutTable--> <TR> <TD COLSPAN=16> <IMG SRC="../embedded-images/head1.gif" WIDTH=775 HEIGHT=41 ALT=""></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=41 ALT=""></TD> </TR> <TR> <TD COLSPAN=2> <A HREF="#" ONMOUSEOVER="window.status='Home'; changeImages('Home', '../embedded-images/Home-over.gif'); return true;" ONMOUSEOUT="window.status=''; changeImages('Home', '../embedded-images/Home.gif'); return true;"> <IMG NAME="Home" SRC="../embedded-images/Home.gif" WIDTH=68 HEIGHT=37 BORDER=0 ALT="Home"></A></TD> <TD width="66"> <A HREF="#" ONMOUSEOVER="window.status='Company'; changeImages('Company', '../embedded-images/Company-over.gif'); return true;" ONMOUSEOUT="window.status=''; changeImages('Company', '../embedded-images/Company.gif'); return true;"> <IMG NAME="Company" SRC="../embedded-images/Company.gif" WIDTH=66 HEIGHT=37 BORDER=0 ALT="Company"></A></TD> <TD COLSPAN=2> <A HREF="#" ONMOUSEOVER="window.status='Products'; changeImages('Products', '../embedded-images/Products-over.gif'); return true;" ONMOUSEOUT="window.status=''; changeImages('Products', '../embedded-images/Products.gif'); return true;"> <IMG NAME="Products" SRC="../embedded-images/Products.gif" WIDTH=71 HEIGHT=37 BORDER=0 ALT="Products"></A></TD> <TD COLSPAN=4> <A HREF="#" ONMOUSEOVER="window.status='Careers'; changeImages('Careers', '../embedded-images/Careers-over.gif'); return true;" ONMOUSEOUT="window.status=''; changeImages('Careers', '../embedded-images/Careers.gif'); return true;"> <IMG NAME="Careers" SRC="../embedded-images/Careers.gif" WIDTH=66 HEIGHT=37 BORDER=0 ALT="Careers"></A></TD> <TD> <A HREF="#" ONMOUSEOVER="window.status='Info'; changeImages('Info', '../embedded-images/Info-over.gif'); return true;" ONMOUSEOUT="window.status=''; changeImages('Info', '../embedded-images/Info.gif'); return true;"> <IMG NAME="Info" SRC="../embedded-images/Info.gif" WIDTH=41 HEIGHT=37 BORDER=0 ALT="Info"></A></TD> <% if (session.getAttribute("login.username") != null) { %> <TD> <A HREF="#" ONMOUSEOVER="window.status='Contact Us'; changeImages('Contact_Us', '../embedded-images/Contact-Us-over.gif'); return true;" ONMOUSEOUT="window.status=''; changeImages('Contact_Us', '../embedded-images/Contact-Us.gif'); return true;"> <IMG NAME="Contact_Us" SRC="../embedded-images/Contact-Us.gif" WIDTH=84 HEIGHT=37 BORDER=0 ALT="Contact Us"></A></TD> <% } else {%> <TD><IMG SRC="../embedded-images/Contact-Us-blank.gif" WIDTH=84 HEIGHT=37 BORDER=0></TD> <% } %> <TD COLSPAN=5> <IMG SRC="../embedded-images/head2.gif" WIDTH=379 HEIGHT=37 ALT=""></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=37 ALT=""></TD> </TR> <TR> <TD COLSPAN=16> <IMG SRC="../embedded-images/head3.gif" WIDTH=775 HEIGHT=161 ALT=""></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=161 ALT=""></TD> </TR> <TR> <TD COLSPAN=7> <% if (session.getAttribute("login.username") != null) { %> <IMG SRC="../embedded-images/user_info.gif" WIDTH=234 HEIGHT=27 ALT=""></TD> <% } else {%> <IMG SRC="../embedded-images/sign_in.gif" WIDTH=234 HEIGHT=27 ALT=""></TD> <% } %> <TD ROWSPAN=14> <IMG SRC="../embedded-images/si2.gif" WIDTH=17 HEIGHT=626 ALT=""></TD> <TD ROWSPAN=14> <IMG SRC="../embedded-images/au1.gif" WIDTH=20 HEIGHT=626 ALT=""></TD> <TD COLSPAN=3 ROWSPAN=2> <IMG SRC="../embedded-images/about_us.gif" WIDTH=229 HEIGHT=39 ALT=""></TD> <TD ROWSPAN=14> <IMG SRC="../embedded-images/au2.gif" WIDTH=22 HEIGHT=626 ALT=""></TD> <TD COLSPAN=2 ROWSPAN=3> <IMG SRC="../embedded-images/prod1.gif" WIDTH=245 HEIGHT=89 ALT=""></TD> <TD ROWSPAN=14> <IMG SRC="../embedded-images/so1.gif" WIDTH=8 HEIGHT=626 ALT=""></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=27 ALT=""></TD> </TR> <TR> <TD ROWSPAN=3> <IMG SRC="../embedded-images/si1.gif" WIDTH=5 HEIGHT=104 ALT=""> </TD> <TD COLSPAN=6 ROWSPAN=3 align="center" valign="middle"> <jsp:include page="/embeddedchild-tomcat.do"/> </TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=12 ALT=""> </TD> </TR> <TR> <TD COLSPAN=3 ROWSPAN=9 align="left" valign="top"><div align="justify">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. At vero eos et accusam et justo duo dolores et ea. At vero eos et accusam et justo duo dolores et ea.<br> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. At vero eos et accusam et justo duo dolores et ea. At vero eos et accusam et justo duo dolores et ea.<br> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. At vero eos et accusam et justo duo dolores et ea. At vero eos et accusam et justo duo dolores et ea.<br> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. At vero eos et accusam et justo duo dolores et ea. At vero eos et accusam et justo duo dolores et ea. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. At vero eos et accusam.</div></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=50 ALT=""></TD> </TR> <TR> <% if (session.getAttribute("login.username") != null) { %> <TD ROWSPAN=3> <IMG SRC="../embedded-images/prod1_buy_member.gif" ALT="" WIDTH=139 HEIGHT=126 border="0" usemap="#Map5"></TD> <TD ROWSPAN=3 align="left" valign="top">This powerful machine with 450W power supply can even be used as a server.</TD> <% } else { %> <TD ROWSPAN=3> <IMG SRC="../embedded-images/prod1_buy.gif" ALT="" WIDTH=139 HEIGHT=126 border="0" usemap="#Map5"></TD> <TD ROWSPAN=3 align="left" valign="top">This powerful machine with 450W power supply can even be used as a server.<br><br> Log in and get instant $50 off!</TD> <% } %> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=42 ALT=""></TD> </TR> <TR> <TD COLSPAN=7> <IMG SRC="../embedded-images/latest_news.gif" WIDTH=234 HEIGHT=37 ALT=""></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=37 ALT=""></TD> </TR> <TR> <TD ROWSPAN=9> <IMG SRC="../embedded-images/si1-31.gif" WIDTH=5 HEIGHT=458 ALT=""></TD> <TD COLSPAN=6 ROWSPAN=8 align="left" valign="top"><div align="justify"><span class="text1">20/02/2004</span><br> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. At vero eos et accusam et justo duo dolores et ea. At vero eos et accusam et justo duo dolores et ea. </div> <p align="right"><a href="#">Read more</a><img src="../embedded-images/bullet.gif" border="0" align="absbottom" usemap="#Map2"></p> <p align="left"><span class="text1">18/02/2004</span><br> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. At vero eos et accusam et justo duo dolores et ea. At vero eos et accusam et justo duo dolores et ea.</p> <p align="right"><a href="#">Read more</a><img src="../embedded-images/bullet.gif" border="0" align="absbottom" usemap="#Map3"></p> <p align="justify"><span class="text1">17/02/2004</span><br> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. At vero eos et accusam et justo duo dolores et ea. At vero eos et accusam et justo duo dolores et ea.</p> <p align="right"><a href="#">Read more</a><img src="../embedded-images/bullet.gif" border="0" align="absbottom" usemap="#Map4"></p></TD> <TD height="47"> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=47 ALT=""></TD> </TR> <TR> <TD height="67" COLSPAN=2> <IMG SRC="../embedded-images/prod2.gif" WIDTH=245 HEIGHT=67 ALT=""></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=67 ALT=""></TD> </TR> <TR> <% if (session.getAttribute("login.username") != null) { %> <TD ROWSPAN=3> <IMG SRC="../embedded-images/prod2_buy_member.gif" ALT="" WIDTH=139 HEIGHT=130 border="0" usemap="#Map6"></TD> <TD ROWSPAN=3 align="left" valign="top"> Desktop machine with ergonomic flat panel monitor. </TD> <% } else { %> <TD ROWSPAN=3> <IMG SRC="../embedded-images/prod2_buy.gif" ALT="" WIDTH=139 HEIGHT=130 border="0" usemap="#Map6"></TD> <TD ROWSPAN=3 align="left" valign="top"> Desktop machine with ergonomic flat panel monitor.<br><br> Log in and get instant $50 off! </TD> <% } %> <TD height="5"> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=5 ALT=""></TD> </TR> <TR> <TD height="14"> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=14 ALT=""></TD> </TR> <TR> <TD height="111"> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=111 ALT=""></TD> </TR> <TR> <TD COLSPAN=2 ROWSPAN=2> <IMG SRC="../embedded-images/prod3.gif" WIDTH=245 HEIGHT=62 ALT=""></TD> <TD height="16"> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=16 ALT=""></TD> </TR> <TR> <TD COLSPAN=3 ROWSPAN=3> <IMG SRC="../embedded-images/au3.gif" WIDTH=229 HEIGHT=198 ALT=""></TD> <TD height="46"> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=46 ALT=""></TD> </TR> <TR> <% if (session.getAttribute("login.username") != null) { %> <TD ROWSPAN=2> <IMG SRC="../embedded-images/prod3_buy_member.gif" ALT="" WIDTH=139 HEIGHT=152 border="0" usemap="#Map7"></TD> <TD height="130" align="left" valign="top">19-inch flat panel monitor with only 64K colors, but with 8ms response time. <% } else { %> <TD ROWSPAN=2> <IMG SRC="../embedded-images/prod3_buy.gif" ALT="" WIDTH=139 HEIGHT=152 border="0" usemap="#Map7"></TD> <TD height="130" align="left" valign="top">19-inch flat panel monitor with only 64K colors, but with 8ms response time.<br><br>Gamers, log in and get instant $50 off! <% } %> </TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=130 ALT=""></TD> </TR> <TR> <TD COLSPAN=6> <IMG SRC="../embedded-images/si3.gif" WIDTH=229 HEIGHT=22 ALT=""></TD> <TD> <IMG SRC="../embedded-images/so2.gif" WIDTH=106 HEIGHT=22 ALT=""></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=22 ALT=""></TD> </TR> <TR> <TD COLSPAN=16> <IMG SRC="../embedded-images/footer.gif" WIDTH=775 HEIGHT=27 ALT=""></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=27 ALT=""></TD> </TR> <TR> <TD COLSPAN=16 align="center" valign="top"> <div align="center"><a href="#">Home</a> | <a href="#">Company</a> | <a href="#">Products</a> | <a href="#">Info</a> | <a href="#">News</a> | <a href="#">Support</a> | <a href="#">Careers</a> | <a href="#">Site Map</a> | <a href="#">Contact Us</a> <p>© Copyright Your Company Name. Designed by <a href="http://www.templatesbox.com/templates/072.htm">TemplatesBox.com</a></p> </div></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=1 HEIGHT=64 ALT=""></TD> </TR> <TR> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=5 HEIGHT=1 ALT=""></TD> <TD width="63"> <IMG SRC="../embedded-images/spacer.gif" WIDTH=63 HEIGHT=1 ALT=""></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=66 HEIGHT=1 ALT=""></TD> <TD width="15"> <IMG SRC="../embedded-images/spacer.gif" WIDTH=15 HEIGHT=1 ALT=""></TD> <TD width="56"> <IMG SRC="../embedded-images/spacer.gif" WIDTH=56 HEIGHT=1 ALT=""></TD> <TD width="8"> <IMG SRC="../embedded-images/spacer.gif" WIDTH=8 HEIGHT=1 ALT=""></TD> <TD width="21"> <IMG SRC="../embedded-images/spacer.gif" WIDTH=21 HEIGHT=1 ALT=""></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=17 HEIGHT=1 ALT=""></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=20 HEIGHT=1 ALT=""></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=41 HEIGHT=1 ALT=""></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=84 HEIGHT=1 ALT=""></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=104 HEIGHT=1 ALT=""></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=22 HEIGHT=1 ALT=""></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=139 HEIGHT=1 ALT=""></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=106 HEIGHT=1 ALT=""></TD> <TD> <IMG SRC="../embedded-images/spacer.gif" WIDTH=8 HEIGHT=1 ALT=""></TD> <TD></TD> </TR> </TABLE> <!-- End ImageReady Slices --> <map name="Map"> <area shape="rect" coords="5,45,78,64" href="#" alt="GO"> </map> <map name="Map2"> <area shape="rect" coords="3,2,19,12" href="#" alt="Read more"> </map> <map name="Map3"> <area shape="rect" coords="0,2,29,13" href="#" alt="Read more"> </map> <map name="Map4"> <area shape="rect" coords="0,0,23,13" href="#" alt="Read more"> </map> <map name="Map5"> <area shape="rect" coords="43,87,116,105" href="#" alt="BUY"> </map> <map name="Map6"> <area shape="rect" coords="43,88,116,107" href="#" alt="BUY"> </map> <map name="Map7"> <area shape="rect" coords="43,109,116,129" href="#" alt="BUY"> </map> </center></BODY> </html:html> |
Update of /cvsroot/struts/dialogs/war/sample-selectaction In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19672/war/sample-selectaction Added Files: index.html login.gif readme.txt selectadd.html selectcancel.html selectdelete.html selectlogin.html selectunspecified.html Log Message: --- NEW FILE: index.html --- <!-- SelectAction Example Author: Michael Jouravlev, 2004-2005 Struts Dialogs, http://struts.sourceforge.net/strutsdialogs --> <html> <head> <title>SelectAction Example</title> <meta name="description" content="SelectAction Example" /> <meta name="keywords" content="SelectAction,DispatchAction,Struts Dialogs,Struts,Examples,Samples" > </head> <h2>SelectAction Example</h2> <p>This simple example shows how to dispatch submit events from an HTTP form to handler methods. SelectAction uses request parameter starting with certain prefix to distinguish an event. Default prefix is "DIALOG-EVENT", you can redefine it in <code>getInitKey</code> method.</p> <p>All buttons and links on this page use request parameters, starting with default prefix, like "DIALOG-EVENT-DELETE". Each specific request parameter is mapped to a handler method by <code>getKeyMethodMap</code> method.</p> <p>See source code for this page for better understanding of dispatch request parameters.</p> <form action="selectaction.do" method="post"> <input type="hidden" name="DIALOG-DEFAULT-EVENT" value="DIALOG-EVENT-DELETE" /> <h3>Image buttons, pushbuttons and links are handled uniformly</h3> <p>This is a dummy text field to check how default submit works on different browsers. "Default submit" means submitting a form by hitting Enter key in the text field instead of clicking a submit button. When form is submitted without clicking a button, a browser either submits the first button defined in the form, or does not submit any buttons.</p> <p> For this sample page, Mozilla/Firefox will submit the first input element defined on the form, and will generate "login" event. Internet Explorer will not submit any buttons, and SelectAction will call <code>unspecified</code> method.<br><br> Test default submit: <input type="text" SIZE="20"><hr></p> <p>"DIALOG-EVENT-LOGIN" is mapped to <code>login</code> method. This image button Works fine with MSIE too.</p> <input type="image" name="DIALOG-EVENT-LOGIN" src="login.gif" value="Log In"><hr> <p>"DIALOG-EVENT-ADD" is mapped to <code>add</code> method.</p> <input type="submit" name="DIALOG-EVENT-ADD" value="Add button" /> <a href="selectaction.do?DIALOG-EVENT-ADD=1">Add link</a><hr> <p>"DIALOG-EVENT-DELETE" is mapped to <code>delete</code> method.</p> <input type="submit" name="DIALOG-EVENT-DELETE" value="Delete button fancy caption" /> <a href="selectaction.do?DIALOG-EVENT-DELETE=1">Delete link</a><hr> <p>"DIALOG-EVENT-anything" correctly starts with event prefix, but is not mapped to any method, exception is thrown.</p> <input type="submit" name="DIALOG-EVENT-anything" value="No corresponding handler (exception)" /> <a href="selectaction.do?DIALOG-EVENT-anything=1">No corresponding handler (exception)</a><hr> <p>"unknown-prefix" button name and query parameter do not start with event prefix. For a button default "delete" handler will be used, defined in a hidded fieild: <input type="hidden" name="DIALOG-DEFAULT-EVENT" value="DIALOG-EVENT-DELETE"/></p> <p>For link <code>unspecified</code> method will be called, because link does not submit an HTML form.</p> <input type="submit" name="unknown-prefix" value="No dispatch prefix (use default)" /> <a href="selectaction.do?unknown-prefix=1">No dispatch prefix (unspecified)</a><hr> <p>This is a standard <code><html:cancel/></code> button; it is autowired to <code>cancelled</code> method. Link works as well, but client validator is not disabled, because bCancel is not set to true.</p> <input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Standard Cancel button works too" onclick="bCancel=true;"> <a href="selectaction.do?org.apache.struts.taglib.html.CANCEL=1">Standard Cancel handler works for links</a> </form> </html> --- NEW FILE: login.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: readme.txt --- SelectAction example -------------------- SelectAction is an improved version of DispatchAction. It handles pushbuttons, image buttons and regular links uniformly. Allows to set an arbitrary caption for a pushbutton. Button caption does not have to relate to a method name. In the index.html file the following tag... <input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="..." onclick="bCancel=true;"> ...is the HTML code which would be generated by <html:cancel/> button, if index page were a JSP. It is there to verify that cancel button is handled correctly. You can use SelectAction separately from Struts Dialogs library. --- NEW FILE: selectadd.html --- <html> <h2>ADD</h2> </html> --- NEW FILE: selectcancel.html --- <html> <h2>CANCEL</h2> </html> --- NEW FILE: selectdelete.html --- <html> <h2>DELETE</h2> </html> --- NEW FILE: selectlogin.html --- <html> <h2>LOGIN</h2> </html> --- NEW FILE: selectunspecified.html --- <html> <h2>UNSPECIFIED</h2> </html> |
From: <jm...@us...> - 2005-08-04 07:40:09
|
Update of /cvsroot/struts/dialogs/war/sample-logincontrol In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19672/war/sample-logincontrol Added Files: index.html Log Message: --- NEW FILE: index.html --- <!-- Struts Dialogs Example Author: Michael Jouravlev, 2004-2005 --> <html> <head> <title>Struts Dialogs Examples</title> <meta name="description" content="Struts Dialogs Examples" /> <meta name="keywords" content="Struts Dialogs,Examples,Samples" > <base> </head> <blockquote> <h2>DialogAction, embedded login control</h2> <p>Login control is a JSP component. It is embedded in the master page using simple JSP include: </p> <pre> <%@ page contentType="text/html;charset=UTF-8" language="java" %> ... <TABLE> ... <TR> <TD> <jsp:include page="/logincomponent.do"/> </TD> </TR> ... </TABLE> </pre> <p>Notice, that user's input is submitted directly to the control, therefore there is no need in central controller or something like portlet container to collect requests and then to dispatch them to controls, using separate API.</p> <p>After you log in, the main page is reloaded. Login control will display "Log Out" button and "Contact Us" link will be enabled. Login control uses the same session variable to store a name of logged in user, as login dialog and login component. So, you may be already logged in.</p> <p>JSP control may not even know that it was embedded into master page. Java code for this embedded JSP control is the same as for standalone <a href="http://www.superinterface.com/strutsdialog/logincomponent.html">login component.</a></p> <a href="../embedded-tomcat.do">Live demo of embedded login control</a><br> <br> </blockquote> </html> |
From: <jm...@us...> - 2005-08-04 07:40:09
|
Update of /cvsroot/struts/dialogs/war/sample-logindialog In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19672/war/sample-logindialog Added Files: index.html login.jsp userpage.jsp Log Message: --- NEW FILE: index.html --- <!-- Struts Dialogs Example Author: Michael Jouravlev, 2004-2005 --> <html> <head> <title>Struts Dialogs Examples</title> <meta name="description" content="Struts Dialogs Examples" /> <meta name="keywords" content="Struts Dialogs,Examples,Samples" > <base> </head> <blockquote> <h2>DialogAction, login dialog</h2> <p>DialogAction allows creating robust web components and web controls, which enhibit friendly user experience, react properly to Refresh, Back and Forward buttons, and do not cause implicit double submits or annoying POSTDATA messages.</p> <p>DialogAction, which used to create the Login Dialog, provides the following capabilities:</p> <ul> <li>handles initialization event;</li> <li>buffers error messages;</li> <li>renders view corresponding to component state;</li> <li>stores state (in an action form);</li> <li>separates input and output processes (using POST-redirect-GET pattern)</li> </ul> <p>Use the "init" link to reset and clear Login Dialog with a special initialization request parameter. Login name and password used on last login attempt are cleared, and a current user is logged out.<br> <a href="logindialog.do?DIALOG-EVENT-INIT=dummy">Login Dialog (init)</a></p> <p>Use the "current view" link to see the current state of Login Dialog. If you attempted to log in, then the login form will contain the name and password you used last.<br> <a href="logindialog.do">Login Dialog (current view)</a></p> <hr> <img src="strutsdialogs-power.gif" ALT=""> </blockquote> </html> --- NEW FILE: login.jsp --- <!-- Struts Dialogs Examples, Login Dialog Author: Michael Jouravlev, 2004-2005 --> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <html:html> <head> <title>Login Dialog</title> <html:base/> </head> <body> <h2>Login Dialog</h2> <!-- Standard Struts error handling --> <logic:messagesPresent> <html:messages id="error"> <li><bean:write name="error"/></li> </html:messages> <br> </logic:messagesPresent> <!-- Login form; only one form is available for a dialog by definition --> <html:form action="/sample-logindialog/logindialog.do"> <input type="hidden" name="DIALOG-DEFAULT-EVENT" value="DIALOG-EVENT-LOGIN" /> <table border="1" width="300" > <tr> <td colspan="2" align="left" bgcolor="#FF9966">Log in</td> </tr> <tr> <td align="left" bgcolor="#FF9966">User name:</td> <td><html:text name="loginform" property="name" size="15" tabindex="1"/></td> </tr> <tr> <td align="left" bgcolor="#FF9966">User password:</td> <td><html:text name="loginform" property="password" size="15" tabindex="2"/></td> </tr> <tr> <td colspan="2" align="right" bgcolor="#FF9966"> <input type="submit" size="10" name="DIALOG-EVENT-LOGIN" value="Log In"> </td> </tr> </table> </html:form> <hr> <p>Valid login/password combination is <b>guest/guest</b>.</p> <p>Try to enter an invalid login/password combination, then refresh a page. Notice that POSTDATA message is not presented by browser. Error message is gone after refresh, it is automatically cleaned up by Struts (since 1.2.6).</p> <p>Enter invalid login/password combination several times, then click Back browser button. Notice, that browser immediately brings you back to the description page, no matter how many login attempts you made.</p> <p>Use "init" link on <a href="index.html">description page</a> to reset and clear the dialog content and to log out the current user.</p> </body> </html:html> --- NEW FILE: userpage.jsp --- <!-- Struts Dialogs Examples, Login Dialog Author: Michael Jouravlev, 2004-2005 --> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <!-- If user is not logged in, redirect to login page --> <% if (session.getAttribute("login.username") == null) { response.sendRedirect("logindialog.do"); } %> <html:html locale="true"> <head> <title>User home page</title> </head> <body> <h2>Home page</h2> <!-- Show sample user page --> <table border="1" width="300"> <tr> <td align="left" bgcolor="#FFCC66"> Welcome, <%= session.getAttribute("login.username") %>! </td> </tr> <tr> <td align="left" bgcolor="#FFCC66"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. </td> </tr> </table> <p>Use Back browser button to return to previous page.</p> </body> </html:html> |