Bugs item #1339904, was opened at 2005-10-27 19:53
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=684975&aid=1339904&group_id=119783
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Sven Meier (svenmeier)
Assigned to: Nobody/Anonymous (nobody)
Summary: ComponentStringResourceLoader unusable for nested panels
Initial Comment:
The way ComponentStringResourceLoader currently loads
messages has the following problems when using multiple
and/or nested panels in a form:
- a panel inside a form has to know the id of this
containing form for its validation messages, e.g.
form.foo.RequiredValidator=Foo is required.
- for two panels in the same form, each having a
component with the same id, the validation message
cannot be changed independently, e.g. impossible to do
form.foo.RequiredValidator=Foo in first panel is
required.
form.foo.RequiredValidator=Foo in second panel is
required.
Hence I propose to change the following two classes:
ValidatorResourceKeyFactory.java
... should omit the form's id from the validator
resource key:
public String newKey(IValidator validator,
FormComponent component)
{
return component.getId() + "." +
Classes.name(validator.getClass());
}
ComponentStringResourceLoader.java
... should prefix the message key with the path of the
overriding component (here named hierarchicalKey):
// Build search stack
Stack searchStack = new Stack();
searchStack.push(component);
String hierarchicalKey = key;
if (!(component instanceof Page))
{
MarkupContainer c = component.getParent();
while (true)
{
searchStack.push(c);
if (c instanceof Page)
break;
hierarchicalKey = c.getId() + "." + hierarchicalKey;
c = c.getParent();
}
}
// Iterate through search stack
String value = null;
while (!searchStack.isEmpty())
{
Component c = (Component)searchStack.pop();
Class cc = c.getClass();
while ( value == null ) {
// Locate previously loaded resources from the cache
final String id = createCacheId(cc, style, locale);
ValueMap strings = (ValueMap)resourceCache.get(id);
if (strings == null)
{
// No resources previously loaded, attempt to
load them
strings = loadResources(c, cc, style, locale, id);
}
// Lookup value
value = strings.getString(hierarchicalKey);
if (value != null)
break;
// Move to next superclass
cc = cc.getSuperclass();
if (isStopResourceSearch(cc)) break;
}
if (value != null) {
break;
} else {
hierarchicalKey =
hierarchicalKey.substring(hierarchicalKey.indexOf('.')
+ 1);
}
}
// Return the resource value (may be null if resource
was not found)
return value;
Note that this change will require some message
property files to be adjusted. See user-list for more
details.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=684975&aid=1339904&group_id=119783
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop