• 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
Setting display name for entity in DirectToWeb
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Setting display name for entity in DirectToWeb


  • Subject: Setting display name for entity in DirectToWeb
  • From: Johan Henselmans <email@hidden>
  • Date: Thu, 16 Feb 2006 12:25:33 +0100

I have a DirectToWeb application, in which the names that are created for the tables or entities, are not clear for the users, so I have to rename the displayed name. It seems that that is not possible directly, there is no "displayNameForEnity".

I found a mail from 2002 that exactly described my problem,

http://www.wodeveloper.com/omniLists/webobjects-dev/2002/February/ msg00504.html,

where Max Muller describes a solution.

The solution was to extend the Assignment class, and then add a rule to rename the entity in the display.

however, when I tried the code I could not get it to work with the rule engine, apparently I am doing something wrong. Can somebody shed some light?


The rule I tried was with was this one:
======================================================================== ==========
{
author = 50;
class = "com.webobjects.directtoweb.Rule";
lhs = {
class = com.webobjects.eocontrol.EOKeyValueQualifier;
key = "entity.name";
selectorName = "isEqualTo";
value = Performance;
};
rhs = {
class = MyDefaultNameAssignment;
keyPath = displayNameForEntity;
value = Vorstellung;
};
},
======================================================================== ==========





It was fired when I turned on -D2WTraceRuleFiringEnabled YES

I saw this in the log:

(entity.name = 'Performance') => displayNameForEntity=Vorstellung (java.lang.String) (60001)

The extended class was this one:
======================================================================== ==========
public class MyDefaultNameAssignment extends Assignment {


public static Object decodeWithKeyValueUnarchiver (EOKeyValueUnarchiver eokeyvalueunarchiver) {
return new MyDefaultNameAssignment(eokeyvalueunarchiver);
}


     public MyDefaultNameAssignment (EOKeyValueUnarchiver u) {
	super(u);
     }
     public MyDefaultNameAssignment (String key, Object value) {
	super(key,value);
      }

public Object fire(D2WContext c) {
String displayName = null;
if (keyPath().equals("displayNameForEntity"))
displayName = displayNameForKey((String)c.valueForKeyPath ("entity.name"));
else if (keyPath().equals("displayNameForProperty"))
displayName = displayNameForKey((String)c.valueForKey("propertyKey"));
else
throw RuntimeException("Attempting to use MyDefaultNameAssignment for unsupported key: " + keyPath());
return displayName;
}


public static String displayNameForKey(String key) {
StringBuffer finalString = new StringBuffer();
if (key != null) {
NSArray keys=NSArray.componentsSeparatedByString(key,".");
String lastHop=(String)keys.objectAtIndex(keys.count()-1);
StringBuffer tempString = new StringBuffer();
char[] originalArray = lastHop.toCharArray();
originalArray[0] = Character.toUpperCase(originalArray [0]);
Character tempChar = null;
Character nextChar = null;
for(int i=0;i<(originalArray.length-1);i++){
tempChar = new Character(originalArray[i]);
nextChar = new Character(originalArray[i+1]);
if(Character.isUpperCase(originalArray[i]) &&
Character.isLowerCase(originalArray[i+1])) {
finalString.append(tempString);
if (i>0) finalString.append(' ');
tempString = new StringBuffer();
}
tempString.append(tempChar.toString());
}
finalString.append(tempString);
finalString.append(nextChar);
}
return finalString.toString();
}
}


======================================================================== ==========

Best Regards,

Johan Henselmans
http://www.netsense.nl
Tel: +31-20-6267538
Fax: +31-20-6273852


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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: Setting display name for entity in DirectToWeb
      • From: Anjo Krank <email@hidden>
    • Re: Setting display name for entity in DirectToWeb
      • From: David Avendasora <email@hidden>
  • Prev by Date: Re: Flattening attributes
  • Next by Date: Re: Setting display name for entity in DirectToWeb
  • Previous by thread: Re: Problem with page encoding
  • Next by thread: Re: Setting display name for entity in DirectToWeb
  • Index(es):
    • Date
    • Thread