You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Martin Makundi <ma...@koodaripalvelut.com> on 2009/08/02 17:21:56 UTC

Re: Problem with Required component message

> I did this by creating a properties file MyPanel.properties and then setting
> creditCardForm.ccNumber.Required=Please enter your credit card number.
> Did you try setting form.componentId.Required? Or even panel.form.componentId.Required

The problem is that my field is on a ListView. I cannot PREDICT the
INDEX!!! It will be: form.listview.*random_index*.componentId.Required

In my opinnion there is a bug in the stringResource-finder. It should
FIRST scan down the path before trying the Key=Required alone. Now it
tries the full path first, then Key=Required and if that is not found,
then it tries the next path depth.

> https://issues.apache.org/jira/browse/WICKET-2350

That's something different. I had a look at the HEAD Wicket svn, this
part of the code still remains:

// First, try the fully qualified resource name relative to the
// component on the path from page down.
... proper code here but FULLY QUALIFIED RESOURCE
Then right after that:

// If not found, than check if a property with the 'key' provided by
			// the user can be found.
			if ((string == null) && old)
			{
				string = loadStringResource(clazz, key, locale, style);
			}

It looks for the key...Required. I.e., it will override with the default one.

In my opinnion the above block "if not found..." should be right after
the LOOP "for (int i = searchStack.size() - 1; (i >= 0) && (string ==
null); i--)" and NOT WITHIN the loop as it is now.

**
Martin


> Russ
>> Date: Sun, 2 Aug 2009 12:19:40 +0300
>> Subject: Problem with Required component message
>> From: martin.makundi@koodaripalvelut.com
>> To: users@wicket.apache.org
>>
>> Hi!
>>
>> I have a page with some required fields among which there is one
>> specific field I want to return a specific required validation error
>> message, if value not given.
>>
>> I have tried to put "componentId.Required=Unique error message" into
>> Application.properties but it does not work. Instead Wicket always
>> returns the standard Required error.
>>
>> Debugging deeper into the problem shows that Wicket constructs a
>> dot-notation component path of the requied component:
>> page.panel.form.nested_panel.listview.index.componentId.Required and
>> tries to look for a property with such name. If not found, it next
>> tries to look for Required alone and if it is found, it returns that
>> (if Required was not found, it would continue dropping one prefix at a
>> time until it would reach the assumed componentId.Required).
>>
>> This code is in:
>> ComponentStringResourceLoader.loadStringResource(final Component
>> component, final String key)
>>
>> Is there a flaw in the logic or am I doing something wrong here?
>>
>> **
>> Martin
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
> _________________________________________________________________
> Get back to school stuff for them and cashback for you.
> http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1