I've prepared a patch with a new event: the copy event.
With this event you can copy the content of the current row in the "new" form. Associated with it there is a new tag, navCopyButton. To test it you can use the bookstore example, I've added "copy" button to testAuthorBookSubForm.jsp, in either parent and child forms.


The patch consist of a patch file and 2 new files:
src/org/dbforms/eventNavCopyEvent.java
src/org/dbforms/taglib/DbNavCopyButtonTag.java

bye,
Sergio Moretti


patch file:
------------------------ CUT HERE --------------------------
? src/org/dbforms/event/NavCopyEvent.java
? src/org/dbforms/taglib/DbNavCopyButtonTag.java
Index: etc/taglib_docu.xml
===================================================================
RCS file: /cvsroot/jdbforms/dbforms/etc/taglib_docu.xml,v
retrieving revision 1.49
diff -u -r1.49 taglib_docu.xml
--- etc/taglib_docu.xml 19 Jul 2003 08:52:17 -0000 1.49
+++ etc/taglib_docu.xml 22 Jul 2003 13:23:56 -0000
@@ -4767,6 +4767,221 @@
<info>The tab order (ascending positive integers) for this element.</info>
</attribute>
</tag>
+ <!-- **************************** navCopyButton tag ***********************************-->
+ <tag>
+ <name>navCopyButton</name>
+ <summary>this tag renders a navigation button for creating a copy of a row of data</summary>
+ <tagclass>org.dbforms.taglib.DbNavCopyButtonTag</tagclass>
+ <bodycontent>JSP</bodycontent>
+ <info>
+ <p>navigation button to scroll to a copy of an existent dataset</p>
+ </info>
+
+ <attribute>
+ <name>id</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>expose id, enables interaction with JavaScript</info>
+ </attribute>
+
+ <attribute>
+ <name>flavor</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>
+ <p>styling of the button</p>
+ choices:
+ <ul>
+ <li>
+ <b>standard</b>
+ a standard form button. if you use it you should specify &quot;caption&quot;
+ </li>
+ <li>
+ <b>image</b>
+ an image-button. if you use it you should specify &quot;src&quot; and &quot;alt&quot;
+ </li>
+ <li>
+ <b>modern</b>
+ a fancy button according to HTML4; dont use if no all of your users have got 5th-generation browsers! You may embed any code into this tag. (see docu or www.w3.org)
+ </li>
+ </ul>
+ </info>
+ </attribute>
+
+ <attribute>
+ <name>caption</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>caption of the button (use it if the chosen flavor is "standard")</info>
+ </attribute>
+
+ <attribute>
+ <name>src</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>source of the image (use it if the coosen flavor is "image")</info>
+ </attribute>
+
+ <attribute>
+ <name>alt</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>alternative to image (use it if the coosen flavor is "image")</info>
+ </attribute>
+
+ <attribute>
+ <name>border</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>set html border attribute</info>
+ </attribute>
+
+ <attribute>
+ <name>followUp</name>
+ <info>
+ <p>site to be invoked after this button has been clicked and the associated actions are done</p>
+ <p>this attribute over-rules the followUp-attribute of the parent form(s)!</p>
+ </info>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+
+ <attribute>
+ <name>followUpOnError</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>
+ <p>site to be invoked after this button has been clicked and the associated actions are done</p>
+ <p>this attribute over-rules the followUpOnError-attribute of the parent form(s)!</p>
+ </info>
+ </attribute>
+
+ <attribute>
+ <name>accessKey</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>The keyboard character used to move focus immediately to this element.</info>
+ </attribute>
+
+ <attribute>
+ <name>onBlur</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>JavaScript event handler executed when this element loses inputfocus.</info>
+ </attribute>
+
+ <attribute>
+ <name>onChange</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>JavaScript event handler executed when this element loses inputfocus and its value has changed.</info>
+ </attribute>
+
+ <attribute>
+ <name>onSelect</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>JavaScipt event hanlder executed when the user selects some text</info>
+ </attribute>
+
+ <attribute>
+ <name>onClick</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>JavaScript event handler executed when this element receives amouse click.</info>
+ </attribute>
+
+ <attribute>
+ <name>onDblClick</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>JavaScript event handler executed when this element receives amouse double click.</info>
+ </attribute>
+
+ <attribute>
+ <name>onFocus</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>JavaScript event handler executed when this element receives inputfocus.</info>
+ </attribute>
+
+ <attribute>
+ <name>onKeyDown</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>JavaScript event handler executed when this element has focus and akey is depressed.</info>
+ </attribute>
+
+ <attribute>
+ <name>onKeyPress</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>JavaScript event handler executed when this element has focus and akey is depressed and released.</info>
+ </attribute>
+
+ <attribute>
+ <name>onKeyUp</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>JavaScript event handler executed when this element has focus and akey is released.</info>
+ </attribute>
+
+ <attribute>
+ <name>onMouseDown</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>JavaScript event handler executed when this element is under the mousepointer and a mouse button is depressed.</info>
+ </attribute>
+
+ <attribute>
+ <name>onMouseMove</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>JavaScript event handler executed when this element is under themouse pointer and the pointer is moved.</info>
+ </attribute>
+
+ <attribute>
+ <name>onMouseOut</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>JavaScript event handler executed when this element was under themouse pointer but the pointer was moved outside the element.</info>
+ </attribute>
+
+ <attribute>
+ <name>onMouseOver</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>JavaScript event handler executed when this element was not underthe mouse pointer but the pointer is moved inside the element.</info>
+ </attribute>
+
+ <attribute>
+ <name>onMouseUp</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>JavaScript event handler executed when this element is under themouse pointer and a mouse button is released.</info>
+ </attribute>
+
+ <attribute>
+ <name>style</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>CSS styles to be applied to this HTML element.</info>
+ </attribute>
+
+ <attribute>
+ <name>styleClass</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>CSS stylesheet class to be applied to this HTML element.</info>
+ </attribute>
+
+ <attribute>
+ <name>tabIndex</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>The tab order (ascending positive integers) for this element.</info>
+ </attribute>
+ </tag>
<!-- **************************** gotoButton tag ***********************************-->
<tag>
<name>gotoButton</name>
Index: examples/bookstore/tests/testAuthorBooksSubForm.jsp
===================================================================
RCS file: /cvsroot/jdbforms/dbforms/examples/bookstore/tests/testAuthorBooksSubForm.jsp,v
retrieving revision 1.2
diff -u -r1.2 testAuthorBooksSubForm.jsp
--- examples/bookstore/tests/testAuthorBooksSubForm.jsp 19 Jul 2003 08:52:19 -0000 1.2
+++ examples/bookstore/tests/testAuthorBooksSubForm.jsp 22 Jul 2003 13:23:56 -0000
@@ -44,6 +44,7 @@
<db:navNextButton style="width:100" caption="> Next"/>
<db:navLastButton style="width:100" caption=">> Last"/>
<db:navNewButton style="width:100" caption="New"/>
+ <db:navCopyButton style="width:100" caption="Copy"/>
&nbsp;
</td>
</tr>
@@ -78,6 +79,7 @@
<db:navNextButton style="width:100" caption="> Next"/>
<db:navLastButton style="width:100" caption=">> Last"/>
<db:navNewButton style="width:100" caption="New"/>
+ <db:navCopyButton style="width:100" caption="Copy"/>
&nbsp;
</td>
</tr>
Index: src/org/dbforms/config/TableEvents.java
===================================================================
RCS file: /cvsroot/jdbforms/dbforms/src/org/dbforms/config/TableEvents.java,v
retrieving revision 1.2
diff -u -r1.2 TableEvents.java
--- src/org/dbforms/config/TableEvents.java 19 Jul 2003 08:52:19 -0000 1.2
+++ src/org/dbforms/config/TableEvents.java 22 Jul 2003 13:23:56 -0000
@@ -60,6 +60,7 @@
addEventInfo(EventType.EVENT_NAVIGATION_GOTO);
addEventInfo(EventType.EVENT_NAVIGATION_LAST);
addEventInfo(EventType.EVENT_NAVIGATION_NEW);
+ addEventInfo(EventType.EVENT_NAVIGATION_COPY);
addEventInfo(EventType.EVENT_NAVIGATION_NEXT);
addEventInfo(EventType.EVENT_NAVIGATION_PREV);
}
Index: src/org/dbforms/event/NavEventFactoryImpl.java
===================================================================
RCS file: /cvsroot/jdbforms/dbforms/src/org/dbforms/event/NavEventFactoryImpl.java,v
retrieving revision 1.9
diff -u -r1.9 NavEventFactoryImpl.java
--- src/org/dbforms/event/NavEventFactoryImpl.java 19 Jul 2003 08:52:20 -0000 1.9
+++ src/org/dbforms/event/NavEventFactoryImpl.java 22 Jul 2003 13:23:56 -0000
@@ -189,6 +189,8 @@
{
addEventInfo(new EventInfo(EventType.EVENT_NAVIGATION_NEW,
"org.dbforms.event.NavNewEvent"));
+ addEventInfo(new EventInfo(EventType.EVENT_NAVIGATION_COPY,
+ "org.dbforms.event.NavCopyEvent"));
addEventInfo(new EventInfo(EventType.EVENT_NAVIGATION_GOTO,
"org.dbforms.event.datalist.GotoEvent"));
addEventInfo(new EventInfo(EventType.EVENT_NAVIGATION_FIRST,
Index: src/org/dbforms/event/eventtype/EventType.java
===================================================================
RCS file: /cvsroot/jdbforms/dbforms/src/org/dbforms/event/eventtype/EventType.java,v
retrieving revision 1.2
diff -u -r1.2 EventType.java
--- src/org/dbforms/event/eventtype/EventType.java 19 Jul 2003 08:52:21 -0000 1.2
+++ src/org/dbforms/event/eventtype/EventType.java 22 Jul 2003 13:24:04 -0000
@@ -66,6 +66,9 @@
/** value of the navigation new event */
public static final String EVENT_NAVIGATION_NEW = "navNew";


+   /**  value of the navigation new event */
+   public static final String EVENT_NAVIGATION_COPY = "navCopy";
+
    /**  value of the navigation goto event */
    public static final String EVENT_NAVIGATION_GOTO = "navGoto";

Index: src/org/dbforms/event/eventtype/NavigationEventTypeStrategy.java
===================================================================
RCS file: /cvsroot/jdbforms/dbforms/src/org/dbforms/event/eventtype/NavigationEventTypeStrategy.java,v
retrieving revision 1.2
diff -u -r1.2 NavigationEventTypeStrategy.java
--- src/org/dbforms/event/eventtype/NavigationEventTypeStrategy.java 19 Jul 2003 08:52:21 -0000 1.2
+++ src/org/dbforms/event/eventtype/NavigationEventTypeStrategy.java 22 Jul 2003 13:24:04 -0000
@@ -65,6 +65,7 @@
|| eventString.startsWith("ac_next_")
|| eventString.startsWith("ac_last_")
|| eventString.startsWith("ac_new_")
+ || eventString.startsWith("ac_copy_")
|| eventString.startsWith("ac_goto_")
|| eventString.equals("navFirst")
|| eventString.equals("navPrev")
@@ -112,6 +113,11 @@
|| eventString.equals("navNew"))
{
eventType = EventType.EVENT_NAVIGATION_NEW;
+ }
+ else if (eventString.startsWith("ac_copy_")
+ || eventString.equals("navCopy"))
+ {
+ eventType = EventType.EVENT_NAVIGATION_COPY;
}
else if (eventString.startsWith("ac_goto_") || eventString.equals("goto"))
{
Index: src/org/dbforms/taglib/DbBaseHandlerTag.java
===================================================================
RCS file: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbBaseHandlerTag.java,v
retrieving revision 1.9
diff -u -r1.9 DbBaseHandlerTag.java
--- src/org/dbforms/taglib/DbBaseHandlerTag.java 19 Jul 2003 08:52:22 -0000 1.9
+++ src/org/dbforms/taglib/DbBaseHandlerTag.java 22 Jul 2003 13:24:07 -0000
@@ -29,7 +29,9 @@
import java.util.Vector;
import org.dbforms.util.ParseUtil;
import org.dbforms.config.*;
+import org.dbforms.event.NavigationEvent;
import org.dbforms.event.ReloadEvent;
+import org.dbforms.event.NavCopyEvent;
import org.dbforms.event.WebEvent;
import javax.servlet.http.HttpServletRequest;


@@ -702,6 +704,13 @@
}
else
{
+ NavigationEvent ne = (NavigationEvent) request.getAttribute("webEvent");
+ if (ne instanceof NavCopyEvent){
+ String copyValue = ParseUtil.getParameter(request, getFormFieldNameForCopyEvent());
+ if (copyValue != null)
+ return copyValue;
+ }
+
// the form field is in 'insert-mode'
if (we instanceof ReloadEvent)
{
@@ -775,6 +784,17 @@
}


return buf.toString();
+ }
+
+ /**
+ * generates the decoded name for the html-widget in the case of copy events.
+ */
+ private String getFormFieldNameForCopyEvent() {
+ boolean footerReached = parentForm.getFooterReached();
+ parentForm.setFooterReached(false);
+ String name = getFormFieldName();
+ parentForm.setFooterReached(footerReached);
+ return name;
}
-------------------------------------- CUT HERE ------------------------



FILE: src/org/dbforms/eventNavCopyEvent.java
------------------------- CUT HERE -----------------------------
/*
* $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/event/NavNewEvent.java,v 1.5 2003/07/19 08:52:20 hkollmann Exp $
* $Revision: 1.5 $
* $Date: 2003/07/19 08:52:20 $
*
* DbForms - a Rapid Application Development Framework
* Copyright (C) 2001 Joachim Peer <[EMAIL PROTECTED]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.dbforms.event;


import java.sql.Connection;
import java.sql.SQLException;

import javax.servlet.http.HttpServletRequest;

import org.dbforms.config.DbFormsConfig;
import org.dbforms.config.Table;
import org.dbforms.util.FieldValue;
import org.dbforms.util.ParseUtil;
import org.dbforms.util.ResultSetVector;

/**
*
* <p>This event signalizes to the framework that the user wants to initialize a new dataset
* with values coming from current row</p>
* #fixme: lousy description
*
* @author Stefano Borghi <[EMAIL PROTECTED]>
*
* @version $Revision$
*
*/
public class NavCopyEvent extends NavigationEvent {


        /**
         * Creates a new NavNewEvent object.
         *
         * @param action DOCUMENT ME!
         * @param request DOCUMENT ME!
         * @param config DOCUMENT ME!
         */
        public NavCopyEvent(
                String action,
                HttpServletRequest request,
                DbFormsConfig config) {
                super(action, request, config);
                this.config = config;
                tableId = ParseUtil.getEmbeddedStringAsInteger(action, 2, '_');
                this.table = config.getTable(tableId);
        }

        /**
         * Creates a new NavNewEvent object.
         *
         * @param table DOCUMENT ME!
         * @param config DOCUMENT ME!
         */
        public NavCopyEvent(
                Table table,
                HttpServletRequest request,
                DbFormsConfig config) {
                super(table, request, config);
                this.table = table;
                this.tableId = table.getId();
                this.config = config;
        }

/* (non-Javadoc)
* @see org.dbforms.event.NavigationEvent#processEvent(org.dbforms.util.FieldValue[], org.dbforms.util.FieldValue[], int, java.lang.String, java.lang.String, java.sql.Connection, java.lang.String)
*/
public ResultSetVector processEvent(
FieldValue[] childFieldValues,
FieldValue[] orderConstraint,
int count,
String firstPost,
String lastPos,
Connection con,
String dbConnectionName)
throws SQLException {
logCat.info("processed NavCopyEvent");
return null;
}


}
-------------------------- CUT HERE --------------------------


FILE: src/org/dbforms/taglib/DbNavCopyButtonTag.java
--------------------------- CUT HERE -------------------------
/*
* $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbNavFirstButtonTag.java,v 1.9 2003/07/19 08:52:22 hkollmann Exp $
* $Revision: 1.9 $
* $Date: 2003/07/19 08:52:22 $
*
* DbForms - a Rapid Application Development Framework
* Copyright (C) 2001 Joachim Peer <[EMAIL PROTECTED]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.dbforms.taglib;


import javax.servlet.jsp.JspException;

import org.apache.log4j.Category;
import org.dbforms.validation.ValidatorConstants;

/**
 * <p>this tag renders an "copy"-button.
 *
 * @author Stefano Borghi <[EMAIL PROTECTED]>
 *
 * @version $Revision$
 *
 */
public class DbNavCopyButtonTag extends DbBaseButtonTag {
        static Category logCat =
                Category.getInstance(DbNavCopyButtonTag.class.getName());
        // logging category for this class

public int doStartTag() throws javax.servlet.jsp.JspException {

// ValidatorConstants.JS_CANCEL_SUBMIT is the javascript variable boolean to verify
// if we do the javascript validation before submit <FORM>
if (parentForm.getFormValidatorName() != null
&& parentForm.getFormValidatorName().length() > 0
&& parentForm.getJavascriptValidation().equals("true")) {
String onclick = (getOnClick() != null) ? getOnClick() : "";
if (onclick.lastIndexOf(";") != onclick.length() - 1)
onclick += ";"; // be sure javascript end with ";"
setOnClick(
onclick + ValidatorConstants.JS_CANCEL_VALIDATION + "=true;");
}


// if(parentForm.getFooterReached() && ResultSetVector.isEmptyOrNull(parentForm.getResultSetVector()) ) return EVAL_PAGE;

                try {
                        StringBuffer tagBuf = new StringBuffer();
                        String tagName = "ac_copy_" + table.getId();
                        if (followUp != null) {
                                tagBuf.append(getDataTag(tagName, "fu", followUp));
                        }
                        if (followUpOnError != null) {
                                tagBuf.append(getDataTag(tagName, "fue", 
followUpOnError));
                        }
                        tagBuf.append(getButtonBegin());
                        tagBuf.append(" name=\"");
                        tagBuf.append(tagName);
                        tagBuf.append("\">");

                        pageContext.getOut().write(tagBuf.toString());
                } catch (java.io.IOException ioe) {
                        throw new JspException("IO Error: " + ioe.getMessage());
                }

                if (choosenFlavor == FLAVOR_MODERN)
                        return EVAL_BODY_BUFFERED;
                else
                        return SKIP_BODY;
        }

public int doEndTag() throws javax.servlet.jsp.JspException {

                if (choosenFlavor == FLAVOR_MODERN) {
                        try {
                                if (bodyContent != null)
                                        
bodyContent.writeOut(bodyContent.getEnclosingWriter());
                                pageContext.getOut().write("</button>");
                        } catch (java.io.IOException ioe) {
                                throw new JspException("IO Error: " + 
ioe.getMessage());
                        }
                }
                return EVAL_PAGE;
        }

}
--------------------------- CUT HERE ----------------------------



-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
DbForms Mailing List

http://www.wap-force.net/dbforms

Reply via email to