No -- this is a component action, not a direct action (it has to have the object being referenced). 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.
ms On Mar 31, 2008, at 10:49 PM, Archibald Singleton wrote: Is this supposed to work with a direct action?
E.g.: <wo:ERXDataHyperlink directActionName = "editPerson" person = "$person">edit person<wo:ERXDataHyperlink>
I'm asking because I tried it and the person binding just yield and entree attribute for the <a> tag. Looking at the implementation of ERXDataHyperlink I don't seem to see any reason why it wouldn't work.
So, what am I missing?
TIA
= tmk = On 31 Mar 2008, at 09:58, Mike Schrag wrote: In Wonder, ERXDataHyperlink --
<wo:ERXDataHyperlink pageName = "EditPersonPage" person = "$person">edit person<wo:ERXDataHyperlink>
You can pass in multiple variables, as well ...
ms On Mar 31, 2008, at 12:51 AM, Chris Meyer wrote: > Code comment: Ooo ick - using public ivars in your api! - wrap that > person with accessors!
If I'm lazy enough to want to avoid writing minimal action functions then surely I'm lazy enough to skip accessors of nominal value.
> <cough>DirectToWeb</cough>
Might work for some stuff (the classes in my example, for instance)... but not for the general case. My question was more for the general case.
OK, answering my question, here's a component that does it. Seems like this (with a rename, validation, and probably other industrializing cleanup) might be nice for WOnder.
IteratedLink.java:
package com.lqgraphics.webreg.components;
import com.webobjects.appserver.*;
public class IteratedLink extends com.webobjects.appserver.WOComponent { public IteratedLink(WOContext context) { super(context); }
public boolean isStateless() { return true; }
public WOComponent action() { Object value = this.valueForBinding("value"); String key = (String)valueForBinding("field"); WOComponent component = this.pageWithName((String)valueForBinding("pageName")); component.takeValueForKey(value, key); return component; } }
IteratedLink.html:
<wo:link action="$action"><wo:WOComponentContent/></wo:link>
IteratedLink.api (lazy version, no validation):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <wodefinitions> <wo wocomponentcontent="false" class="IteratedLink.java">
<binding name="pageName"/> <binding name="field"/> <binding name="value"/>
</wo> </wodefinitions>
On Sun, Mar 30, 2008 at 8:11 PM, David LeBer < email@hidden> wrote: On 30-Mar-08, at 10:44 PM, Chris Meyer wrote: > One pattern I find myself using often is that I have a page listing > my objects (PeopleList) and a detail page (PersonDetail). > > In my PeopleList component, I have a WORepetition of WOHyperlink's > linking to specific PersonDetails. > > To facilitate the hyperlink, I have an action in PeopleList.java > that creates a new PeopleDetail page and sets the iterated Person in > the WORepetition into a variable on that new page. > > My questions: > > Is this the right design pattern to use? > > If so, is there any way to use ognl or some other mechanism to avoid > writing the action method in PeopleList.java that loads the new page > and sets the Person variable on the new page? > > If not, is there any fundamental reason why this cannot be done > automatically (with some syntax modifications/improvements in the > WOParser, or whatever)? <cough>DirectToWeb</cough> Failing that, create some superclasses for you components to inherit from that contain the generic behaviour you want: ListPage.java public EOEnterpriseObject listItem; public String detailsPageName; // set in your subclass; ... public WOComponent goToDetailsPage() { WOComponent nextPage = pageWithName(detailsPageName); nextPage.takeValueForKey(listItem, "detailItem"); return nextPage; } DetailsPage.java private EOEnterpriseObject _detailItem; private WOComponent _backPage; public DetailsPage(WOContext context) { super(context); setBackPage(this.context().page()); } public EOEnterpriseObject detailItemt() { return _detailsItem; } public void setDetailItem(EOEnterpriseObject obj) { _detailItem = obj; } public WOComponent backPage() { return _backPage; } public void setBackPage(WOComponent page) { _backPage = page; } public WOComponent saveChanges() { WOComponent nextPage = backPage(); try { detailItem.editingContext().saveChanges(); } catch (Exception e) { // EXAMPLE ONLY :-) nextPage = null; } return nextPage; } > PeopleList.wo: > > <ul> > <wo:WORepetition list="people" item="person"> > <li><wo:WOHyperlink action=""><wo:string > value="$person.name"/></wo:WOHyperlink></li> > </wo:WORepetition> > </ul> > > PeopleList.java > > class PeopleList > { > public Person person; > > // can this be avoided? > public WOComponent gotoPersonDetail() > { > PersonDetail pd = > (PersonDetail)pageWithName(PersonDetail.class.getSimpleName()); > pd.person = person; > return pd; > } > } > > PersonDetail.java > > class PersonDetail > { > public Person person; > } Code comment: Ooo ick - using public ivars in your api! - wrap that person with accessors! ;david -- David LeBer Codeferous Software 'co-def-er-ous' adj. Literally 'code-bearing' site: http://codeferous.com blog: http://davidleber.net profile: http://www.linkedin.com/in/davidleber -- Toronto Area Cocoa / WebObjects developers group: http://tacow.org _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription:
|