Re: Hyperlinks and action methods
Re: Hyperlinks and action methods
- Subject: Re: Hyperlinks and action methods
- From: Archibald Singleton <email@hidden>
- Date: Tue, 1 Apr 2008 00:31:58 -0300
On 01 Apr 2008, at 00:14, Mike Schrag wrote:
No -- this is a component action, not a direct action (it has to
have the object being referenced).
Right, overlooked that.
If you want to do it on a direct action, just do a normal
hyperlink with ?personID=person.primaryKey and reload the person
in the DA.
Yeah, that's what I was doing but I liked the elegance of
ERXDataHyperlink.
We have something similar to Rails routes/controllers coming to
Wonder sometime soon for the more directaction-y case ... We've been
using them for a couple months, but it just hasn't made it upstream
yet. So you can do things like
<wo:EntityLink record = "$person">link to person</wo:EntityLink>
<wo:EntityLink record = "$person" type = "xml">link to person</
wo:EntityLink>
<wo:EntityLink entityName = "Person" action = "list">people</
wo:EntityLink>
<wo:EntityLink entityName = "Person" action = "create">people</
wo:EntityLink>
and it will look for page components (named by convention, though
they must implement a particular interface as a security measure).
So for instance it will look for PersonListXmlPage, or
PersonListPage (for standard HTML) and generate URLs like /entity/
Person/5 or /entity/Person/list or /entity/Person/create. You can
also map query string parameters to component methods by annotating
certain methods of your component with an @EntityParameter
annotation. In code, you can have your action methods return things
like:
return EntityActionFactory.redirectForEntity(EntityRouter.LIST,
AdCategory.ENTITY_NAME, context(), false);
so you can easily redirect to nice URLs after performing certain
actions. You can also register custom entity routers so you can
process the "id" part in special ways (for instance we have it
hooked to ERTaggable with a custom EntityRouter that does /entity/
Tag/accounting and it will return the entities tagged "accounting".
None of this is magic by any means, it's just a convenient handful
of classes for doing it easily. What I like about them is that it
makes it very easy to mix and match normal component actions with
easy RESTful style URLs whenever it makes sense to do so.
Looks really nice and elegant indeed.
I look forward to this stuff showing up in WOnder.
= tmk =
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden