• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Hyperlinks and action methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hyperlinks and action methods


  • Subject: Re: Hyperlinks and action methods
  • From: Lachlan Deck <email@hidden>
  • Date: Tue, 1 Apr 2008 16:06:37 +1100

On 01/04/2008, at 2:14 PM, 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>

Nice. Yeah I've got something similar...

BatchLink : DynamicDirectAction {
	object = parentPage.pageTag;
	actionClass = "List";
	directActionName = pluralEntityName.toLowerCase;
	queryPrefix = "tag"; /* creates e.g., ?tag=234[&tag=34...] */
	?page = listItem;
}
which is later transformed, IIRC, to .../pluralEntityName/path/to/tag

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.

Cool. That will be nice.

If it's of any interest what I did was override the direct action request handler to figure out which DirectAction class to use (Detail, List). You can see this in action here, for example: http://www.sydneycommunitycollege.com.au/

The rules are quite simple:
- if DirectAction action class and actionName exist use as is (e.g., .../wa/[DirectAction/]default)
- else if we have a plural entity name to start --> List
e.g., http://www.sydneycommunitycollege.com.au/courses/arts/drama


- else if we have a singular entity name to start --> Detail
	http://www.sydneycommunitycollege.com.au/course/ardr1

- else assume we might have a tag-path name --> Detail (e.g., 'history' tag with parent 'about')
http://www.sydneycommunitycollege.com.au/about/history


The remainder of the url, i.e., beyond the first /.../, is deciphered according to custom rules depending on whether it's List or Detail.

All in all, the urls are quite short and easier to remember + there's hardly any fiddling in apache.

with regards,
--

Lachlan Deck

Attachment: ISHDirectActionRequestHandler.java
Description: Binary data

 _______________________________________________
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

References: 
 >Hyperlinks and action methods (From: "Chris Meyer" <email@hidden>)
 >Re: Hyperlinks and action methods (From: David LeBer <email@hidden>)
 >Re: Hyperlinks and action methods (From: "Chris Meyer" <email@hidden>)
 >Re: Hyperlinks and action methods (From: Mike Schrag <email@hidden>)
 >Re: Hyperlinks and action methods (From: Archibald Singleton <email@hidden>)
 >Re: Hyperlinks and action methods (From: Mike Schrag <email@hidden>)
 >Re: Hyperlinks and action methods (From: Archibald Singleton <email@hidden>)
 >Re: Hyperlinks and action methods (From: Mike Schrag <email@hidden>)

  • Prev by Date: Re: [OT] Limiting File Upload Sizes
  • Previous by thread: Re: Hyperlinks and action methods
  • Next by thread: derby examples
  • Index(es):
    • Date
    • Thread