You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Christian Oldiges (JIRA)" <ji...@apache.org> on 2008/10/23 15:18:44 UTC

[jira] Created: (WICKET-1888) FormComponents (and subclasses) should be able to provide their own resource bundles

FormComponents (and subclasses) should be able to provide their own resource bundles
------------------------------------------------------------------------------------

                 Key: WICKET-1888
                 URL: https://issues.apache.org/jira/browse/WICKET-1888
             Project: Wicket
          Issue Type: Improvement
          Components: wicket
    Affects Versions: 1.3.4
            Reporter: Christian Oldiges
            Priority: Minor


In order to fully support the idea to break down a large application into small reusable components it seems necessary that FormComponents provide their own resource bundles. We have a project that uses a customized subclass of Checkbox that needs to provide customized error messages. The ideal place for those error messages would be a resource bundle living next to the Checkbox subclass but this is not yet supported. Unfortunately the JavaDoc for ComponentStringResourceLoader indicates (see example: input1.properties => Required) that support for this already exists.

A small change to FormComponent$MessageSource.getMessage(String key) could add support for this. Instead of using the formComponent.getParent() as the base for searching the resource string, simply use the formComponent itself.



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-1888) FormComponents (and subclasses) should be able to provide their own resource bundles

Posted by "Juergen Donnerstag (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1888?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12660078#action_12660078 ] 

Juergen Donnerstag commented on WICKET-1888:
--------------------------------------------

This is the code copied from 1.4 trunk


			final Localizer localizer = formComponent.getLocalizer();

			String resource = prefix + getId() + "." + key;

			// First use the parent for resolving so that
			// form1.textfield1.Required can be used.
			String message = getString(localizer, resource, formComponent.getParent());

			// If not found, than ...
			if (Strings.isEmpty(message))
			{
				// Try a variation of the resource key
				resource = prefix + key;
				message = getString(localizer, resource, formComponent.getParent());
			}

			if (Strings.isEmpty(message))
			{
				// If still empty then use default
				resource = prefix + getId() + "." + key;
				message = getString(localizer, resource, formComponent);

				// If not found, than ...
				if (Strings.isEmpty(message))
				{
					// Try a variation of the resource key
					resource = prefix + key;
					message = getString(localizer, resource, formComponent);
				}
			}

Based on that code, formComponent.getParent() is just the first attempt. If that fails formComponent is used.


> FormComponents (and subclasses) should be able to provide their own resource bundles
> ------------------------------------------------------------------------------------
>
>                 Key: WICKET-1888
>                 URL: https://issues.apache.org/jira/browse/WICKET-1888
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.3.4
>            Reporter: Christian Oldiges
>            Priority: Minor
>
> In order to fully support the idea to break down a large application into small reusable components it seems necessary that FormComponents provide their own resource bundles. We have a project that uses a customized subclass of Checkbox that needs to provide customized error messages. The ideal place for those error messages would be a resource bundle living next to the Checkbox subclass but this is not yet supported. Unfortunately the JavaDoc for ComponentStringResourceLoader indicates (see example: input1.properties => Required) that support for this already exists.
> A small change to FormComponent$MessageSource.getMessage(String key) could add support for this. Instead of using the formComponent.getParent() as the base for searching the resource string, simply use the formComponent itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-1888) FormComponents (and subclasses) should be able to provide their own resource bundles

Posted by "Juergen Donnerstag (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1888?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12660195#action_12660195 ] 

Juergen Donnerstag commented on WICKET-1888:
--------------------------------------------

Though this is true, you still can defined your own "Required" string. Please see ValidatorPropertiesTest for some examples. Assume

MyPage.myPanel.myForm.myTextfield

you could still do any of the following:
MyPage.properties: myPanel.myForm.myTextfield.Required = My Text
MyPage.properties: Required = My Text
MyPanel.properties: myForm.myTextfield.Required = My Text
MyPanel.properties: Required = My Text
MyTextField.properties: myTextfield.Required = My Text
MyTextField.properties: Required = My Text



> FormComponents (and subclasses) should be able to provide their own resource bundles
> ------------------------------------------------------------------------------------
>
>                 Key: WICKET-1888
>                 URL: https://issues.apache.org/jira/browse/WICKET-1888
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.3.4
>            Reporter: Christian Oldiges
>            Priority: Minor
>
> In order to fully support the idea to break down a large application into small reusable components it seems necessary that FormComponents provide their own resource bundles. We have a project that uses a customized subclass of Checkbox that needs to provide customized error messages. The ideal place for those error messages would be a resource bundle living next to the Checkbox subclass but this is not yet supported. Unfortunately the JavaDoc for ComponentStringResourceLoader indicates (see example: input1.properties => Required) that support for this already exists.
> A small change to FormComponent$MessageSource.getMessage(String key) could add support for this. Instead of using the formComponent.getParent() as the base for searching the resource string, simply use the formComponent itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-1888) FormComponents (and subclasses) should be able to provide their own resource bundles

Posted by "Christian Oldiges (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1888?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12660212#action_12660212 ] 

Christian Oldiges commented on WICKET-1888:
-------------------------------------------

Well, here is my case (using 1.3.5, but the code didnt change for 1.4, right?). 
The structure is: MyPage.MyForm.MyFragment.CustomCheckbox

There is the MyFragment inbetween which is used to for a wizard style form, but it should not have any influence on this problem.
Additionally I am using the .xml files instead of .properties which again should not have any impact.

CustomCheckbox does a setRequired(true) in its constructor and is supposed to provide its own error msg in case the checkbox hasnt been checked by the user. This is used all over the application and is therefore put into a custom component (you know DRY ...)

There is a CustomCheckbox.xml file next to the class file in the package structure. Its contains one entry:

<entry key="Required">CUSTOM CHECKBOX TEXT</entry>

There is a MyPage.xml file next to the class file of the MyPage class.

Now if I dont put an entry for "CustomCheckboxID.Required" into MyPage.xml, the standard Required from "Application.properties" text will be shown, which means the "Required" entry in "CustomCheckbox.xml" is ignored, as described in the original posting.

If I put an entry in MyPage.xml like this:

<entry key="CustomCheckboxID.Required">PAGE TEXT</entry>

The text "PAGE TEXT" is picked up. But in my case the last example:

MyTextField.properties: Required = My Text

does not work. The reason is, that the formComponent's parent is tried first and it is succesful in picking up the "Required" entry from the Application.properties file. Thus the formComponent resources are never ever tried.


BTW; The 2. last example "myTextfield.Required" is not really useful, because the instance id of the component should never be known by the component itself during development time. So the "myTextfield." part is not known during development.

> FormComponents (and subclasses) should be able to provide their own resource bundles
> ------------------------------------------------------------------------------------
>
>                 Key: WICKET-1888
>                 URL: https://issues.apache.org/jira/browse/WICKET-1888
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.3.4
>            Reporter: Christian Oldiges
>            Priority: Minor
>
> In order to fully support the idea to break down a large application into small reusable components it seems necessary that FormComponents provide their own resource bundles. We have a project that uses a customized subclass of Checkbox that needs to provide customized error messages. The ideal place for those error messages would be a resource bundle living next to the Checkbox subclass but this is not yet supported. Unfortunately the JavaDoc for ComponentStringResourceLoader indicates (see example: input1.properties => Required) that support for this already exists.
> A small change to FormComponent$MessageSource.getMessage(String key) could add support for this. Instead of using the formComponent.getParent() as the base for searching the resource string, simply use the formComponent itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-1888) FormComponents (and subclasses) should be able to provide their own resource bundles

Posted by "Christian Oldiges (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1888?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12660081#action_12660081 ] 

Christian Oldiges commented on WICKET-1888:
-------------------------------------------

The problem is, that the getString() call for formComponent.getParent() wont fail ever, because it will go all the way up to the Application resource file and there it finds the "Required" string. So the formComponent itself will never be tried and thus has no chance to provide its own "Required" string.

> FormComponents (and subclasses) should be able to provide their own resource bundles
> ------------------------------------------------------------------------------------
>
>                 Key: WICKET-1888
>                 URL: https://issues.apache.org/jira/browse/WICKET-1888
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.3.4
>            Reporter: Christian Oldiges
>            Priority: Minor
>
> In order to fully support the idea to break down a large application into small reusable components it seems necessary that FormComponents provide their own resource bundles. We have a project that uses a customized subclass of Checkbox that needs to provide customized error messages. The ideal place for those error messages would be a resource bundle living next to the Checkbox subclass but this is not yet supported. Unfortunately the JavaDoc for ComponentStringResourceLoader indicates (see example: input1.properties => Required) that support for this already exists.
> A small change to FormComponent$MessageSource.getMessage(String key) could add support for this. Instead of using the formComponent.getParent() as the base for searching the resource string, simply use the formComponent itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (WICKET-1888) FormComponents (and subclasses) should be able to provide their own resource bundles

Posted by "Juergen Donnerstag (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1888?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Juergen Donnerstag resolved WICKET-1888.
----------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.4.5
         Assignee: Juergen Donnerstag

as mentioned in the previous comment, it has been fixed in 1.4

> FormComponents (and subclasses) should be able to provide their own resource bundles
> ------------------------------------------------------------------------------------
>
>                 Key: WICKET-1888
>                 URL: https://issues.apache.org/jira/browse/WICKET-1888
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.3.4
>            Reporter: Christian Oldiges
>            Assignee: Juergen Donnerstag
>            Priority: Minor
>             Fix For: 1.4.5
>
>
> In order to fully support the idea to break down a large application into small reusable components it seems necessary that FormComponents provide their own resource bundles. We have a project that uses a customized subclass of Checkbox that needs to provide customized error messages. The ideal place for those error messages would be a resource bundle living next to the Checkbox subclass but this is not yet supported. Unfortunately the JavaDoc for ComponentStringResourceLoader indicates (see example: input1.properties => Required) that support for this already exists.
> A small change to FormComponent$MessageSource.getMessage(String key) could add support for this. Instead of using the formComponent.getParent() as the base for searching the resource string, simply use the formComponent itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-1888) FormComponents (and subclasses) should be able to provide their own resource bundles

Posted by "Juergen Donnerstag (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1888?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12660228#action_12660228 ] 

Juergen Donnerstag commented on WICKET-1888:
--------------------------------------------

fixed it in 1.4 trunk. 1.3 to come

> FormComponents (and subclasses) should be able to provide their own resource bundles
> ------------------------------------------------------------------------------------
>
>                 Key: WICKET-1888
>                 URL: https://issues.apache.org/jira/browse/WICKET-1888
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.3.4
>            Reporter: Christian Oldiges
>            Priority: Minor
>
> In order to fully support the idea to break down a large application into small reusable components it seems necessary that FormComponents provide their own resource bundles. We have a project that uses a customized subclass of Checkbox that needs to provide customized error messages. The ideal place for those error messages would be a resource bundle living next to the Checkbox subclass but this is not yet supported. Unfortunately the JavaDoc for ComponentStringResourceLoader indicates (see example: input1.properties => Required) that support for this already exists.
> A small change to FormComponent$MessageSource.getMessage(String key) could add support for this. Instead of using the formComponent.getParent() as the base for searching the resource string, simply use the formComponent itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.