if you have two buttons: <t:submit value="message:save"> <t:submit t:id="cancel" value="message:cancel">
in java code @Inject private Session _session; @Inject private ComponentResources _resources; private boolean isCancel; public void onSelectedFromCancel(){ isCancel = true; } public void onSuccess(){ if(isCancel){ _session.evict(_entity);//it is forgotten now _resources.triggerEvent("cancel", new Object[0],null); }else{ boolean isNew = _entity.getId() == null; _session.saveOrUpdate(_entity); _resources.triggerEvent("entitySaved", new Object[]{_entity.getId(), _entity, isNew},null); } } this way your component gives more information on what happened and parent component can add extra logic I've mentioned before onEntitySaved(id, entity, isNew) onCancel() I've actualy encapsulated all this into a Generic component so in my impl there is extra code using TypeCoercer for translating entity id for some operations. Davor Hrg On Wed, Mar 5, 2008 at 3:46 PM, Angelo Chen <[EMAIL PROTECTED]> wrote: > > Hi Davor, > > This is interesting, can you give a simple but complete sample how it works? > thanks. > > A.C. > > > > Davor Hrg wrote: > > > > > > I for enitity editing have a component > > and throw new events based on button clicked; > > > > then capture them > > onEntitySaved(id, entity, isNew) > > onCancel() > > > > this way outside component need not know about buttons inside.. > > but can rely on event names.. > > > > When I have parent enitity form that embeds child entity form > > I can then do: > > onEntitySavedFromChildForm(id, child,isNew){ > > if(isNew) child.setParent(parent); > > } > > > > > > to generate your own event: > > > > @Inject private ComponentResources _resources; > > .... > > _resources.triggerEvent("entitySaved", new Object[]{_entityId, > > _entity, isNew}, null); > > > > > > Davor Hrg > > > > -- > View this message in context: > http://www.nabble.com/T5%3A-determine-button-clicked-in-a-beaneditor-tp15841944p15851594.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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]