Re: WOHyperlinks following recursive relationships in a component
Re: WOHyperlinks following recursive relationships in a component
- Subject: Re: WOHyperlinks following recursive relationships in a component
- From: Colin Clark <email@hidden>
- Date: Fri, 21 Jan 2005 17:48:40 -0500
Hey David!
The simplest way to approach this is to use different action methods for each hyperlink. I don't think it's a bad solution because in essence you do have several different actions from a functional viewpoint. In other words, the application behaves differently depending on if the user is displaying the previous, next, or current image. If your only concern with this is the amount of duplicated code, you can always factor it something like this:
private WOComponent displayImage(Image imageToDisplay) {
DisplayImage nextPage = (DisplayImage) pageWithname("DisplayImage");
nextPage.setAnImage(imageToDisplay);
// Do any other page setup here.
return nextPage;
}
public WOComponent displayNextImage() {
return displayImage(anImage.nextImage());
}
public WOComponent displayPreviousImage() {
return displayImage(anImage.previousImage());
}
This design still involves a lot of code, but it's always a bit more elegant than just copy-pasting a bunch of nearly identical action methods.
I hope that helps,
Colin
On Friday, January 21, 2005, at 12:43 PM, David Holt wrote:
Hello,
I have a component that displays images called DisplayImage. It has WOhyperlinks to previous image, next image, parent image, and child images.
I created an instance of my image object called anImage and bound the WOString for the text of each hyperlink to follow the corresponding relationship (i.e. previous image is anImage.prevImage.image_name). Here is my code for the action binding on the hyperlinks:
public DisplayImage toDisplayImage()
{
DisplayImage nextPage = (DisplayImage)pageWithName("DisplayImage");
// Initialize your component here
nextPage.setAnImage(anImage);
return nextPage;
}
For the links that follow relationships, the link displays just the same image again instead of the related image. Is there a way to set up my WOHyperlinks so that they can pass the value of the related images? i.e. How do I pass the object that anImage.prevImage.Image_name points to to the DisplayImage page? Also, I wanted to call the same action from all of the WOHyperlinks because they all pass different Image objects to the same component. Is this possible, or do I have to call a separate action with each link?
Thanks,
David
_______________________________________________
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
---
Colin Clark
Dynamic Web and Database Development Lead,
Resource Centre for Academic Technology,
University of Toronto
(416) 946-7592 / email@hidden
_______________________________________________
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