Issue Details (XML | Word | Printable)

Key: XW-501
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: tm_jee
Reporter: Vlad Kravchenko
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XWork

VisitorFieldValidator loses original TextProvider

Created: 28/Mar/07 11:37 AM   Updated: 12/Jun/08 09:40 AM
Component/s: Validators
Affects Version/s: 1.2.1
Fix Version/s: 1.2.3, 2.1.2

File Attachments: 1. Java Source File VisitorFieldValidator.java (7 kB)
2. Zip Archive VisitorFieldValidatorTextProviderTest.zip (3 kB)



 Description  « Hide
VisitorFieldValidator creates its own validation context which doesn't use Action's implementation of TextProvider interface.

See forum
http://forums.opensymphony.com/thread.jspa?threadID=73335&tstart=0



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
tm_jee added a comment - 08/Apr/07 08:32 PM
Hi guys,
Pushing this issue to "future", as it might possibly break some existing feature of webwork. See the forum thread for more details.

cheers

tm_jee added a comment - 30/Jun/07 11:13 AM
I'm thinking that maybe we could do it this way, in DelegatingValidatorContext.java
instead of
public static TextProvider makeTextProvider(Object object, LocaleProvider localeProvider) {
        if (object instanceof TextProvider) {
            return (TextProvider) object;
        } else {
                return new TextProviderSupport(object.getClass(), localeProvider);
        }
    }

we could use
public static TextProvider makeTextProvider(Object object, LocaleProvider localeProvider) {
        if (object instanceof TextProvider) {
            return (TextProvider) object;
        } else {
            // the object argument passed through here will most probably be an ActionSupport decendant which does
            // implements TextProvider.
            if ((object != null) && (object instanceof TextProvider)) {
                 return new CompositeTextProvider(new TextProvider[] {
                                ((TextProvider) object),
                                new TextProviderSupport(object.getClass(), localeProvider)
                            });
            }
            else {
                return new TextProviderSupport(object.getClass(), localeProvider);
            }
        }
    }

the idea is to have a CompositeTextProvider where we could slot in the action's TextProvider (if one exists) followed by a newly created TextProvider to fall back upon. The CompositeTextProvider will consult each textprovider it is compose of. It accepts an array of TextProvider or List of TextProvider where order is important, the first in the list / array will be consulted first (highter priority)

cheers

tm_jee added a comment - 30/Jun/07 11:19 AM
fixed. changes at:-

Adding src/java/com/opensymphony/xwork/validator/CompositeTextProvider.java
Sending src/java/com/opensymphony/xwork/validator/DelegatingValidatorContext.java
Adding src/test/com/opensymphony/xwork/validator/CompositeTextProviderTest.java
Adding src/test/com/opensymphony/xwork/validator/CompositeTextProviderTestResourceBundle1.properties
Adding src/test/com/opensymphony/xwork/validator/CompositeTextProviderTestResourceBundle2.properties
Transmitting file data .....
Committed revision 1537.

Vlad Kravchenko added a comment - 21/Jul/07 11:31 AM
Hi tm_jee,

I have created a test for the issue. Extract VisitorFieldValidatorTextProviderTest.zip into the src/test/com/opensymphony/xwork/validator dir and run VisitorFieldValidatorTextProviderTest. It will fail.

I have also attached patched VisitorFieldValidator. Put it into src dir and run the test again. The test will succeed. Unfortunately, com.opensymphony.xwork.validator.VisitorFieldValidatorTest test fails with my implementation of the validator.

Could you make best of two implementation?

I haven't found how to re-open the issue ...

Cheers,
Vlad