• 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: Mapping Integer attribute to WOPopupButton list.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mapping Integer attribute to WOPopupButton list.


  • Subject: Re: Mapping Integer attribute to WOPopupButton list.
  • From: Anjo Krank <email@hidden>
  • Date: Sun, 6 Aug 2006 21:26:46 +0200

What we do is create classes like (incomplete, just typed in mail!):

public class SomeState extends Number {
	private SomeState(String code, int value) {
	}
	public final SomeState NEW = new SomeState("NEW", 0);
	public final SomeState EXPIRED = new SomeState("EXPIRED", 1);
	private SOME_STATE[] = new SomeState[] {NEW , EXPIRED}
	public static SomeState someState(int value) { return SOME_STATE[i];}
}

and create accessors for the attributes like

public SomeState someState() {
return SomeState. someState(((Number)storedValueForKey ("someState")).intValue());
}


public void setSomeState(SomeState value) {
	takeStoredValueForKey(value);
}

and let the localization (in Wonder) handle the actual display. With non-numerical attributes, this is a bit easier as you can create a value factory for the attribute (check the docs for EOAttribute). We do this because we have actual code referencing the values... (obj.someState()==SomeState.NEW instead of obj.someState()==0) and some of these attributes actually have logic.

Of course, you could use the userInfo-approach you use to auto- generate the basic code for this.

Cheers, Anjo

Am 06.08.2006 um 17:52 schrieb Q:

I am currently reimplementing parts of an existing legacy web application using WO as a learning exercise (I'm a WO newbie), and have been trying both D2W and regular components. One issue I have encountered with the database I am using is that it uses quite a number of integer fields to represent properties that map to strings when presented to the user. However this mapping is not present in the database, only the legacy application's interface code. (I am not able to modify the database schema)

After playing with D2W for a bit and creating a couple of custom components that were virtually identical it occurred to me that this mapping data doesn't really belong in a custom component, instead it should actually be in the eomodel. So I wrote a custom D2W component to map the integer value to the appropriate display string using some custom keys in the attribute's userinfo dictionary from the eomodel. This appears to be an elegant solution, works nicely and seems to fit well with the WO way of doing things, something I am still becoming familiar with.

Anyway, now that I have something working, I was curious how this actually "should" be done, but a search didn't reveal anything "out there" to actually do this using the eomodel to store the relational mapping.

Have I not looked in the right places, or is it just that nobody does it this way?

How does everyone else do this?


-- Seeya...Q

               -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

                          _____  /  Quinton Dolan - email@hidden
  __  __/  /   /   __/   /      /
     /    __  /   _/    /      /        Gold Coast, QLD, Australia
  __/  __/ __/ ____/   /   -  /            Ph: +61 419 729 806
                    _______  /
                            _\



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40logicunited.com


This email sent to 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
References: 
 >Mapping Integer attribute to WOPopupButton list. (From: Q <email@hidden>)

  • Prev by Date: Wonder's Change Notificacion Framework doesn't work with current version of openJMS [SOLVED]
  • Next by Date: Re: Mapping Integer attribute to WOPopupButton list.
  • Previous by thread: Re: Mapping Integer attribute to WOPopupButton list.
  • Next by thread: Re: Mapping Integer attribute to WOPopupButton list.
  • Index(es):
    • Date
    • Thread