• 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: Statless Component and component Action
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Statless Component and component Action


  • Subject: Re: Statless Component and component Action
  • From: Kieran Kelleher <email@hidden>
  • Date: Mon, 11 Sep 2006 16:52:12 -0400

Hi Ute,

(Try to keep discussion on the list especially since there is most experience on the list :-)

Not sure exactly what you are trying to do, but it may or may not be trivial. Anyway here is a situation I have that might help you approach yours. I have a reusable component (ObjectList) that has a WORepetition that displays a list of objects and has a WOComponentContent inside the repetition allowing me to put custom action hyperlinks in the WOComponentContent that act on the current repetition. The ObjectList component has a settable binding named selectedObject. I check the senderID against elementID to figure out in which repetition the click happened and then I setSelectedObject (pushing its reference to the parent). WO takes it from there in super.invoke where it calls the correct WOComponent action corresponding to the WOHyperlinks in the parent.

Here is how the code that intercepts and pushes the selectedObject up to the parent through the binding.
/** We override invokeAction just so we can see if something inside this reusable component's
WOComponentContent was clicked in the event that this component wraps a WOHyperlink
in the parent of this component. We check this by seeing if the context.senderID*/
public WOActionResults invokeAction(WORequest aRequest, WOContext aContext) {
// Hack to figure out which object index was clicked
if (aContext.senderID() != null) {
if ( aContext.senderID().startsWith( aContext.elementID() ) ) {
// element id example: 0.7.3.1.3
// sender id example: 0.7.3.1.3.6.5.3
// In this example the '5' is the repetition index.

// An action item was clicked within the WOComponentContent
// Figure our the object index
String subElementID = aContext.senderID().substring ( aContext.elementID().length() );
if ( log.isDebugEnabled() ) log.debug("subElementID = " + subElementID );

NSArray elementArray = NSArray.componentsSeparatedByString ( subElementID, "." );
if ( log.isDebugEnabled() ) log.debug( "elementArray = " + elementArray );

// The repetition index is at index 2 (3rd element)
int clickedIndex = Integer.valueOf( elementArray.objectAtIndex ( 2 ).toString() ).intValue();

if ( log.isDebugEnabled() ) log.debug( "Clicked object = " + objects().objectAtIndex( clickedIndex ).toString() );

setSelectedObjectItem( (NSKeyValueCodingAdditions)objects ().objectAtIndex( clickedIndex ) );
}
}

return super.invokeAction(aRequest,aContext);
}




On Sep 10, 2006, at 2:08 PM, Ute Hoffmann wrote:

I have a subcomponent which contains a repetition of links. Inside of the repetition to another sub-component, which contain the actual link with several layout chioce. This subcomponent will get currentLink via a bindig from the repetition of the parent and it will then call a Action which again goes back to the parent which impelements the right method. This subcomponent is in fact used in different contexts and the parentAction name is also handed over to the subcomponent from its parent via a binding.

Right. Everything works as expected. The right text for every link is displayed and so on, but when I click on the action the Subcomponent no longer has the knowledge of the right element, i.e. it always reacts as if I clicked on the last link on the page. So is there a way to have the subcomponent store which element of the repetition it is connected to as it needs this knowledge to resolve the parent action correctly and thus open the right page...? From the documentation rather not.

Or can I hand over the two markers in the component element action call, like I would do in a direct action as additional bindings. I really would prefer not to use direct Actions in this context...

Any idea how I couls tag this information into the hyperlink with the wo action call when the link is created so it is tehre when the link is clicked....?

Thanks for some pointers. This is probably very trivial and I just do not see it...

Regards.
Ute

_______________________________________________ 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
  • Prev by Date: Re: New WOComponent instance
  • Next by Date: Utility to move files into database
  • Previous by thread: Re: Statless Component and component Action
  • Next by thread: WOBrowser
  • Index(es):
    • Date
    • Thread