• 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
Dynamically casting a WOComponent
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dynamically casting a WOComponent


  • Subject: Dynamically casting a WOComponent
  • From: David Holt <email@hidden>
  • Date: Mon, 29 Sep 2008 15:53:25 -0700

I display a different page Component for a user depending on what group they belong to. On each page there is a WOSwitchComponent.  There are navigation buttons to reset the selection in a WOSwitchComponent.

I am using a pageName string that is dynamically generated by adding the group code to the component name.

I would prefer the action method names to remain constant so that I can use the same ERXNavigationMenu labels no matter what group the user belongs to.

To do this, it would seem that I need to dynamically cast the WOComponent that is returned when the button is clicked. Is there a way to do this? Here is what I have tried and trying to setSelection(String) on a generic WOComponent generates a compiler error (obviously). 

As an example setSelection(String) is a method on the Main1 component and a typical action method to move between sections looks like this:

  public WOActionResults toSectionA() {
WOComponent nextPage = null;
ERXNavigationManager.manager().navigationStateForSession(session()).setState(new NSArray(new Object[] {
"my page",
"A. Background"
}));
String usergroupcodestring = _currentUser.surveyGroup().codeNumber();
String pageName = "Main"+usergroupcodestring;
String partSelectionString = "Section"+usergroupcodestring;


nextPage = context().page().pageWithName(pageName);
nextPage.setSelection(partSelectionString+"A");
return nextPage;
}


How do I cast nextPage to the Main1 class so that it can set the selection for the switch component? Or is there a way to setSelection() after the nextPage has been returned and the Class is known?

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

  • Follow-Ups:
    • Re: Dynamically casting a WOComponent
      • From: Chuck Hill <email@hidden>
    • Re: Dynamically casting a WOComponent
      • From: David LeBer <email@hidden>
  • Prev by Date: Re: PageWithName
  • Next by Date: Re: Dynamically casting a WOComponent
  • Previous by thread: Re: PageWithName
  • Next by thread: Re: Dynamically casting a WOComponent
  • Index(es):
    • Date
    • Thread