On Mar 2, 2009, at 9:10 PM, amiel montecillo wrote:

Hello Chuck,

Actually that is what I ended up doing right now. Handling the actions in EMRecipientAjaxGridCell which works fine.

The reason I wanted the action to be handled in the parent is that, I have quite a few grids. Each grid has different EO models. Each model can be deleted/updated from the grid directly. On "Update", the user is taken to the "update" page for that particular model/ item. On "Delete" taken to a confirmation page of that model/ item. ... etc.

So, I wanted to avoid repeatedly writing cell components like EMRecipientAjaxGridCell for each kind of grid.

So each page is different? I'd try to simplify this even more. (and will just briefly say Direct to Web). Name your update / delete pages according to the entity, e.g. UpdateOffice, UpdateCustomer, DeleteOffice, DeleteCustomer where Office, Customer etc is the name of the Entity in the model. Then you only need one grid cell component that can do something like:

public WOComponent update() {
String pageName = "com.foo.bar.updating.Update" + grid().row().entityName();
    UpdatePage updatePage = (UpdatePage) pageWithName(pageName);
    updatePage.setObject(grid().row());
    return updatePage;
}


Another (slightly hacky) idea is to create an interface with methods like update(EOEnterpriseObject) and update(EOEnterpriseObject). Make your top level pages implement this interface. So if this interface is called CRUDPage the update() method becomes:

public WOComponent update() {
    return ((CRUDPage)context().page()).update(grid().row());
}



(I'm kind of lazy ;) ). Am I making sense? (besides the lazy part) ;)

The lazy part is a programmer virtue. Don't even let anyone dissuade you from being as lazy as possible.
http://c2.com/cgi/wiki?LazinessImpatienceHubris


Chuck



On Tue, Mar 3, 2009 at 12:47 PM, Chuck Hill <ch...@global- village.net> wrote:
Hi Amiel,


On Mar 2, 2009, at 8:18 PM, amiel montecillo wrote:

So I tried to do the Chuck way and he was right,

"There are two ways to do things, the Chuck way and the wrong way". :-P



I did get to keep the pieces. Most notably a stacktrace :)

I was not really expecting that. I've had that happen to me before, but I don't recall what caused it.

Why do you need to process the action in Main? Why can't EMRecipientAjaxGridCell handle the action itself? Is it missing some information? Is the action too specific and this component too general? Supply some more details and I will see if I can find a solution for you.


Chuck





Mar 03 12:07:57 EMManager[5555] DEBUG com .ods .marketing.app.emmanager.components.email.EMRecipientAjaxGridCell - parent binding value: delete Mar 03 12:07:57 EMManager[5555] DEBUG com.ods.marketing.app.emmanager.components.Main - DeleteAction called. <-- parent was indeed called! Mar 03 12:07:57 EMManager[5555] WARN NSLog - <com.webobjects.appserver._private.WOComponentRequestHandler>: Exception occurred while handling request:
java.lang.NullPointerException
[2009-3-3 12:7:57 CST] <WorkerThread8> java.lang.NullPointerException
at com .webobjects .appserver ._private .WOComponentReference ._popComponentFromContext(WOComponentReference.java:108) at com .webobjects .appserver ._private .WOComponentReference.invokeAction(WOComponentReference.java:128) at com .webobjects .appserver ._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:105) at com .webobjects .appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java: 115) at er .extensions .components.conditionals.ERXElse.invokeAction(ERXElse.java:43) at com .webobjects .appserver ._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:105) at com .webobjects .appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java: 115) at er.ajax.AjaxDynamicElement.invokeAction(AjaxDynamicElement.java:98) at er.ajax.AjaxUpdateContainer.invokeAction(AjaxUpdateContainer.java:62) at com .webobjects .appserver ._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:105) at com .webobjects .appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java: 115) at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java: 1079) at er.extensions.components.ERXComponent.invokeAction(ERXComponent.java: 92) at com .webobjects .appserver ._private .WOComponentReference.invokeAction(WOComponentReference.java:127) at com .webobjects .appserver ._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:105) at com .webobjects .appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java: 115) at er .extensions .components .ERXWOComponentContent.invokeAction(ERXWOComponentContent.java:217) at com .webobjects .appserver ._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:105) at com .webobjects .appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java: 115) at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java: 1079) at er.extensions.components.ERXComponent.invokeAction(ERXComponent.java: 92) at com .webobjects .appserver ._private .WOComponentReference.invokeAction(WOComponentReference.java:127) at com .webobjects .appserver ._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:105) at com .webobjects .appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java: 115) at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java: 1079) at er.extensions.components.ERXComponent.invokeAction(ERXComponent.java: 92) at com.webobjects.appserver.WOSession.invokeAction(WOSession.java: 1357) at com .webobjects.appserver.WOApplication.invokeAction(WOApplication.java: 1745) at er .extensions .appserver .ajax.ERXAjaxApplication.invokeAction(ERXAjaxApplication.java:49) at er .extensions .appserver.ERXApplication.invokeAction(ERXApplication.java:1622) at com .webobjects .appserver ._private .WOComponentRequestHandler ._dispatchWithPreparedPage(WOComponentRequestHandler.java:206) at com .webobjects .appserver ._private .WOComponentRequestHandler ._dispatchWithPreparedSession(WOComponentRequestHandler.java:298) at com .webobjects .appserver ._private .WOComponentRequestHandler ._dispatchWithPreparedApplication(WOComponentRequestHandler.java:332) at com .webobjects .appserver ._private .WOComponentRequestHandler ._handleRequest(WOComponentRequestHandler.java:369) at com .webobjects .appserver ._private .WOComponentRequestHandler .handleRequest(WOComponentRequestHandler.java:442) at com .webobjects .appserver.WOApplication.dispatchRequest(WOApplication.java:1687) at er .extensions .appserver .ERXApplication.dispatchRequestImmediately(ERXApplication.java:1737) at er .extensions .appserver.ERXApplication.dispatchRequest(ERXApplication.java:1702) at com .webobjects .appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java:144) at com .webobjects .appserver._private.WOWorkerThread.run(WOWorkerThread.java:226)
   at java.lang.Thread.run(Thread.java:595)



On Tue, Mar 3, 2009 at 11:49 AM, Chuck Hill <ch...@global- village.net> wrote:

On Mar 2, 2009, at 7:40 PM, Andrew Lindesay wrote:

Hello Amiel;

I think I understand your question; you have a component in which you want the action to be fired on the parent component? Try to use the "^" as in;

      ^goDelete

This will invoke the method "goDelete" in the parent component.

The problem here is that components are inserted into AjaxGrid cells via WOSwitchComponent and the only bindings are:

ColumnValue: WOSwitchComponent {
      WOComponentName = columnComponentName;
      value = columnValue;
      grid = thisComponent;
}

This situations requires a little trickery or a different design. grid.parent should return the component that holds the grid. So you can do grid().parent().performActionNamed("foo"), but it if breaks you get to keep the pieces. :-)


Chuck





cheers.

The reason I asked this is that I wanted to embed the CRUD component to one of the cells in an AjaxGrid. and needed the "Delete" and "Update" action to be fired in the parent component of the AjaxGrid instead of the CRUD component. So the CRUD can be reusable.

___
Andrew Lindesay
www.lindesay.co.nz



--
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects









--
socket error: unable to connect to 127.0.0.1

--
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects









--
socket error: unable to connect to 127.0.0.1

--
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects






_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to