my advice is : go to t5 source copy paste submit component into your own upgrade it a bit and youoll get all you need.
The submit component calls the selected event on parent component, you must create a component to get events here's source code for submit component that can cancel a from (it is a copy/paste from t5, plus some aditions) and also call onCancel event // Copyright 2007, 2008 The Apache Software Foundation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package tapestryutil.components; import org.apache.tapestry.ComponentEventCallback; import org.apache.tapestry.ComponentResources; import org.apache.tapestry.MarkupWriter; import org.apache.tapestry.TapestryConstants; import org.apache.tapestry.annotations.Environmental; import org.apache.tapestry.annotations.Mixin; import org.apache.tapestry.annotations.Parameter; import org.apache.tapestry.corelib.base.AbstractField; import org.apache.tapestry.corelib.mixins.RenderDisabled; import org.apache.tapestry.internal.services.ComponentResultProcessorWrapper; import org.apache.tapestry.ioc.annotations.Inject; import org.apache.tapestry.services.ComponentEventResultProcessor; import org.apache.tapestry.services.FormSupport; import org.apache.tapestry.services.Heartbeat; import org.apache.tapestry.services.Request; import org.apache.tapestry.services.Traditional; /** * Corresponds to <input type="submit">, a client-side element that can force the enclosing form to submit. The * submit responsible for the form submission will post a notification that allows the application to know that it was * the responsible entity. The notification is named "selected" and has no context. */ public final class Submit2 extends AbstractField { static final String SELECTED_EVENT = "selected"; static final String CANCEL_EVENT = "cancel"; /** * If true (the default), then any notification sent by the component will be deferred until the end of the form * submission (this is usually desirable). */ @Parameter private boolean _defer = true; /** * Determines the button behavior, <b>"submit"</b> - a normal form button, <b>"reset"</b> - reset form (locally), * "cancel" - works like an actionlink, generates a "cancel" event instead of "selected" and the form is not submitted * (if javascript is disabled form will be submitted, and "cancel" event fired as well), * <b>"submitcancel"</b> - works like "cancel" but behaves consistently with and without javascript * submission (this is usually desirable). */ @Parameter(defaultPrefix=TapestryConstants.LITERAL_BINDING_PREFIX) private String _type = "submit"; @Environmental private FormSupport _formSupport; @Environmental private Heartbeat _heartbeat; @Inject private ComponentResources _resources; @Inject private Request _request; @Inject @Traditional private ComponentEventResultProcessor _eventResultProcessor; @SuppressWarnings("unused") @Mixin private RenderDisabled _renderDisabled; public Submit2() { } Submit2(Request request) { _request = request; } void beginRender(MarkupWriter writer) { String inputType = _type.equalsIgnoreCase("reset") ? "reset":"submit"; writer.element("input", "type", inputType, "name", getControlName(), "id", getClientId()); //form will not be submitted (behaves like an action link) and cancel event will be generated if(_type.equalsIgnoreCase("cancel")) writer.attributes("onclick",String.format("document,location='%s';return false;", _resources.createActionLink(CANCEL_EVENT, true))); //submit the form but skip client validation if(_type.equalsIgnoreCase("submitcancel")) writer.attributes("onclick",String.format("$('%s').onsubmit=null", _formSupport.getClientId())); _resources.renderInformalParameters(writer); } void afterRender(MarkupWriter writer) { writer.end(); } @Override protected void processSubmission(String elementName) { String value = _request.getParameter(elementName); if (value == null) return; Runnable sendNotification = new Runnable() { public void run() { // cancel event link will be generated with javascript, if javascript is working this code // will not be reached for type=cancel, however if javascript is disabled we trigger the different event from here boolean isCancel = _type.equalsIgnoreCase("submitcancel") || _type.equalsIgnoreCase("cancel"); String eventType = isCancel ? CANCEL_EVENT : SELECTED_EVENT; ComponentEventCallback callback = isCancel ? new ComponentResultProcessorWrapper(_eventResultProcessor) : null; _resources.triggerEvent(eventType, null, callback); } }; // When not deferred, don't wait, fire the event now (actually, at the end of the current // heartbeat). This is most likely because the Submit is inside a Loop and some contextual // information will change if we defer. if (_defer) _formSupport.defer(sendNotification); else _heartbeat.defer(sendNotification); } // For testing: void setDefer(boolean defer) { _defer = defer; } void setType(String type) { _type = type; } void setup(ComponentResources resources, FormSupport support, Heartbeat heartbeat) { _resources = resources; _formSupport = support; _heartbeat = heartbeat; } } as you can see the code is realy simple, it is easy to get this to support input type=image Davor Hrg On Thu, May 29, 2008 at 9:22 AM, LakshithaS <[EMAIL PROTECTED]> wrote: > > Thanks all for the replies, ctually this onSelected method works only with > submit component. finally i have finished my work using a hidden field. > Still couldn't find a tapestry solution for this matter. > > > > nille hammer wrote: > > > > > > Hi Lakshitha, > > > > the event handler Methods for Submit-Buttons end with "ed". See this for > > an example > > ( > http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry/corelib/components/Submit.html > ) > > rename your methods to: > > onSelectedFromUpload() > > onSelectedFromNext() > > > > That should fix it. > > > > Cheers nillehammer > > > > ----- original Nachricht -------- > > > > Betreff: how to capture the submit event which occured from a input > > type=image > > Gesendet: Mi, 28. Mai 2008 > > Von: LakshithaS<[EMAIL PROTECTED]> > > > >> > >> HI.. all, > >> I have a situation like this, i have a single form and two image buttons > >> (actually i am using <input type="image" instead of <input > >> type="submit"). > >> The problem is identify the which image button has done the form > >> submission. > >> Coz i am doing two tasks from these two image buttons. one is for data > >> saving and one is for image uploading. Is there a way to find which > >> button > >> has done the form submission? > >> > >> i tried like this > >> component Id's are upload and next respectively > >> > >> public void onSelectFromUpload(){ > >> System.out.println("onSelectFromUpload >>>"); > >> nextPage = null; > >> } > >> > >> public void onSelectFromNext(){ > >> System.out.println("onSelectFromNext >>>"); > >> nextPage = "RegistrationStepTwo"; > >> } > >> > >> any idea ? thanks in millions.. > >> -- > >> View this message in context: > >> > http://www.nabble.com/how-to-capture-the-submit-event-which-occured-from-a-i > >> nput-type%3Dimage-tp17511184p17511184.html > >> Sent from the Tapestry - User mailing list archive at Nabble.com. > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > > > > --- original Nachricht Ende ---- > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > -- > View this message in context: > http://www.nabble.com/how-to-capture-the-submit-event-which-occured-from-a-input-type%3Dimage-tp17511184p17529120.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >