Hi Ramsey,

Okay, so you helped me quite a bit here, but of course I have a few follow-up 
questions.  :-D

1)  (the easier one)  how do I change the name for an entity in the 
localization file?
2)  When a validation exception comes from a formatter (the java.text.Format) 
on a text field, the exception is a NSValidation.ValidationException which does 
not have a context like the ERXValidaion does.  Also, because it is thrown 
before it has anything to do with EOF, there is no attribute or eo associated 
with it, so in the contextForException method you don't even know what form is 
throwing it.  How is this usually handled, because this is giving me the 
following error... "The value entered for ? is not valid."  I can grab it on 
the page in validationFailedWithException, but again there's no way to set the 
context.

I'm surprised by how confusing this is for such seemingly simple task.
Thanks again.

-Mike


On Oct 19, 2011, at 6:54 PM, Ramsey Gurley wrote:



On Oct 19, 2011, at 3:41 PM, Michael Gargano wrote:

Hi Ramsey,

I'm a little confused here.  There must be some kind of context that it's using 
by default, because most of the messages are correct.  The other thing I don't 
understand is if there is no attribute() method on ERXValidationException why 
then does the following template string render properly?

"ExceedsMaximumLengthException" = "The value entered for 
<b>@@displayNameForProperty@@</b> exceeds the length of 
<b>@@attribute.width@@</b>.";

Pardon, there IS an attribute() method on ERXValidationException.

I believe if you stick a breakpoint into that method and ERXValidationFactory's 
messageForException() method, you'll get the answers to your questions though 
:-)

Ramsey


Sorry, I guess I just don't fully understand how this mechanism fully works 
yet.  I know you pointed me in a similar direction back in Sep. when I was 
having trouble with the articles displaying properly, but I thought those 
issues were all d2w related.  Now that I'm no longer using any d2w I'm even 
more confused.  :)

Thanks.
-Mike


On Oct 19, 2011, at 4:35 PM, Ramsey Gurley wrote:

Hi Mike,

On Oct 19, 2011, at 10:52 AM, Michael Gargano wrote:

Hi all,

I'm still having some occasional issues with EOF validations (2 things in 
particular)...


1) For some attributes (it seems like attributes that are type intNumber, but 
there may be others too), I'm getting validation error messages that end with 
"?".
I had that problem the other month on all my attributes, but it had to with the 
d2w libs I had in the build path at the time, those are gone now and I don't 
know why this happens or the best way to handle it.

In ERExtensions ValidationTemplate.strings file I see:

"ValueConversionException" = "The value entered for 
<b>@@displayNameForProperty@@</b> is not a valid 
<b>@@attribute.valueClass@@</b>.";

The display name for your property is created correctly because there is a 
displayNameForProperty() method on ERXValidationException.

There's no attribute() method on ERXValidationException, so it goes to the 
validation context object for an answer.

If you don't have a validation delegate to supply a context and you haven't set 
a context manually, you end up with a '?' replacement character.


2) Somewhat related to this... I have some EO attributes with names that make 
sense in the business domain, but should be called something else when surfaced 
to the user.  So, the attribute might be fancyBusinessObjectName, but when I 
catch the exception and show the message I want it to be displayed as "User Non 
Scary Name".

Is there a way to do either of these things without just doing string 
replacements on the message from the exception, perhaps something in userInfo?


Thanks.
-Mike

In the example above, you could add something like:

"PropertyKey.fancyBusinessObjectName" = "User Non Scary Name";

To your english strings file and get the desired results. It's also done as

"MyEntityName.fancyBusinessObjectName" = "User Non Scary Name";

In some places. Not sure which will work for you.


Ramsey




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to