From: <jm...@us...> - 2005-09-23 06:38:12
|
Update of /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/crud In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17798/src/net/jspcontrols/dialogs/actions/crud Modified Files: CRUDAction.java CRUDConstants.java CRUDForm.java ICRUDForm.java Log Message: Added MailReader Demo; Added component RuleSet Index: CRUDAction.java =================================================================== RCS file: /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/crud/CRUDAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CRUDAction.java 4 Aug 2005 07:39:44 -0000 1.2 --- CRUDAction.java 23 Sep 2005 06:37:56 -0000 1.3 *************** *** 103,131 **** Map map = new HashMap(); - // - // Events external to CRUDaction; initialize business data - // - - // Create new item map.put(getInitKey()+"-CREATE", "onCreate"); - // Create new item from existing one map.put(getInitKey()+"-DUPLICATE", "onDuplicate"); - // Update existing item map.put(getInitKey()+"-UPDATE", "onEdit"); - // View existing item map.put(getInitKey()+"-VIEW", "onPreview"); ! // ! // Events, which are triggered within CRUDAction for current item ! // ! ! // Delete current item ! map.put("DIALOG-EVENT-DELETE", "onDelete"); ! // Cancel viewing or editing of current item ! map.put("DIALOG-EVENT-CANCEL", "onCancel"); ! // Persist changes of current item ! map.put("DIALOG-EVENT-SAVE", "onSave"); ! // Close preview mode of existing item ! map.put("DIALOG-EVENT-CLOSE", "onClose"); return map; --- 103,116 ---- Map map = new HashMap(); map.put(getInitKey()+"-CREATE", "onCreate"); map.put(getInitKey()+"-DUPLICATE", "onDuplicate"); map.put(getInitKey()+"-UPDATE", "onEdit"); map.put(getInitKey()+"-VIEW", "onPreview"); ! map.put(getInitKey()+"-DELETE", "onDelete"); ! map.put(getInitKey()+"-CANCEL", "onCancel"); ! map.put(getInitKey()+"-RESET", "onReset"); ! map.put(getInitKey()+"-SAVE", "onSave"); ! map.put(getInitKey()+"-CLOSE", "onClose"); return map; *************** *** 306,309 **** --- 291,318 ---- /** + * Resets form content. This method calls associated action form + * to perform needed cleanup. No messages are generated for this event. + * @return ActionForward object, identifying the target location. + * Created using CRUDConstants.MAPPING_ON_RESET mapping. + * @see CRUDConstants#MAPPING_ON_RESET_SUCCESS + * @see CRUDConstants#MAPPING_ON_RESET_FAILURE + */ + public ActionForward onReset (ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) throws Exception { + ICRUDForm crudForm = (ICRUDForm) form; + ActionMessages messages = crudForm.crudReset(); + + if ((messages == null) || messages.isEmpty()) { + return mapping.findForward(CRUDConstants.MAPPING_ON_RESET_SUCCESS); + } else { + HttpSession session = request.getSession(); + session.setAttribute(Globals.ERROR_KEY, messages); + return mapping.findForward(CRUDConstants.MAPPING_ON_RESET_FAILURE); + } + } + + /** * Closes business item preview page. This method calls associated * action form to perform needed cleanup. No messages are generated *************** *** 410,416 **** --- 419,432 ---- HttpServletRequest request, HttpServletResponse response) throws Exception { + if (form == null) { + throw new IllegalArgumentException("Form bean is not defined"); + } // CRUDAction works with form beans, implementing ICRUDForm ICRUDForm crudForm = (ICRUDForm) form; String uiMode = crudForm.getCrudUIMode(); + if (uiMode == null) { + throw new IllegalStateException( + "UI Mode is not set in form " + form.getClass().getName()); + } return mapping.findForward(uiMode); } Index: CRUDConstants.java =================================================================== RCS file: /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/crud/CRUDConstants.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CRUDConstants.java 11 Jul 2005 07:13:12 -0000 1.1 --- CRUDConstants.java 23 Sep 2005 06:37:56 -0000 1.2 *************** *** 69,72 **** --- 69,80 ---- String MAPPING_ON_CANCEL = "ON-CANCEL"; /** + * Resets content of existing form + */ + String MAPPING_ON_RESET_SUCCESS = "ON-RESET-SUCCESS"; + /** + * Failed to reset content of existing form + */ + String MAPPING_ON_RESET_FAILURE = "ON-RESET-FAILURE"; + /** * Closed preview of existing BO */ Index: CRUDForm.java =================================================================== RCS file: /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/crud/CRUDForm.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CRUDForm.java 4 Aug 2005 07:39:44 -0000 1.2 --- CRUDForm.java 23 Sep 2005 06:37:56 -0000 1.3 *************** *** 56,63 **** } - public String getCRUDUIMode() { - return this.uiMode; - } - /** * Constructs CRUD form. UI Mode must be set to CRUD_UI_MODE_INACTIVE, --- 56,59 ---- Index: ICRUDForm.java =================================================================== RCS file: /cvsroot/struts/dialogs/src/net/jspcontrols/dialogs/actions/crud/ICRUDForm.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ICRUDForm.java 4 Aug 2005 07:39:44 -0000 1.2 --- ICRUDForm.java 23 Sep 2005 06:37:56 -0000 1.3 *************** *** 51,61 **** * <li>Save (store -> CRUD-ON-STORE-SUCCESS/CRUD-ON-STORE-ERROR) * </ul> */ - 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"; /** --- 51,87 ---- * <li>Save (store -> CRUD-ON-STORE-SUCCESS/CRUD-ON-STORE-ERROR) * </ul> + * For finer control of edit state see <code>CRUD_UI_MODE_UPDATE</code> + * and <code>CRUD_UI_MODE_NEW</code>. Whenever one of these two states + * is set, this state must be true as well. + * @see ICRUDForm#CRUD_UI_MODE_UPDATE + * @see ICRUDForm#CRUD_UI_MODE_NEW */ public static final String CRUD_UI_MODE_EDIT = "CRUD-UI-MODE-EDIT"; ! /** ! * Creating and editing of a new item. Corresponding JSP should allow ! * to save data. Operations allowed in this mode: ! * <ul> ! * <li>Cancel (cancel -> CRUD-ON-CANCEL) ! * <li>Save (store -> CRUD-ON-STORE-SUCCESS/CRUD-ON-STORE-ERROR) ! * </ul> ! * @see ICRUDForm#CRUD_UI_MODE_UPDATE ! * @see ICRUDForm#CRUD_UI_MODE_EDIT ! */ ! public static final String CRUD_UI_MODE_NEW = "CRUD-UI-MODE-NEW"; ! ! /** ! * Editing an existing item. Business data must have been loaded from ! * persistent storage. Corresponding JSP should allow to change and save ! * data. Operations allowed in this mode: ! * <ul> ! * <li>Delete (delete -> CRUD-ON-DELETE-SUCCESS/CRUD-ON-DELETE-ERROR) ! * <li>Cancel (cancel -> CRUD-ON-CANCEL) ! * <li>Save (store -> CRUD-ON-STORE-SUCCESS/CRUD-ON-STORE-ERROR) ! * </ul> ! * @see ICRUDForm#CRUD_UI_MODE_EDIT ! * @see ICRUDForm#CRUD_UI_MODE_NEW ! */ ! public static final String CRUD_UI_MODE_UPDATE = "CRUD-UI-MODE-UPDATE"; /** *************** *** 85,88 **** --- 111,115 ---- * @param mode UI mode for this action form * @see ICRUDForm#CRUD_UI_MODE_INACTIVE + * @see ICRUDForm#CRUD_UI_MODE_EDIT * @see ICRUDForm#CRUD_UI_MODE_READONLY */ *************** *** 92,95 **** --- 119,123 ---- * Returns current UI mode for this action form. * @see ICRUDForm#CRUD_UI_MODE_INACTIVE + * @see ICRUDForm#CRUD_UI_MODE_EDIT * @see ICRUDForm#CRUD_UI_MODE_READONLY */ *************** *** 140,143 **** --- 168,177 ---- /** + * Resets content of existing form. This method usually returns null. + * @return non-empty ActionMessages object if could not reset form. + */ + ActionMessages crudReset(); + + /** * Closes preview from of existing item. This method usually returns null. * @return non-empty ActionMessages object if could not close view. |