Localized bean

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Localized bean

Lukasz Lenart
Hi,

If you have time please take a look on this [1], it isn't the final
stage but at least it allows to have different implementations if
needed and I think that's the last static util in Struts codebase ;-)

https://github.com/apache/struts/pull/121


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localized bean

Greg Huber
I remember there was a snapshot build from the trunk that I used to use to
monitor progress, is that still being built here?

On 14 March 2017 at 09:30, Lukasz Lenart <[hidden email]> wrote:

> Hi,
>
> If you have time please take a look on this [1], it isn't the final
> stage but at least it allows to have different implementations if
> needed and I think that's the last static util in Struts codebase ;-)
>
> https://github.com/apache/struts/pull/121
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localized bean

Lukasz Lenart
2017-03-14 10:32 GMT+01:00 Greg Huber <[hidden email]>:
> I remember there was a snapshot build from the trunk that I used to use to
> monitor progress, is that still being built here?

Yeah but only for the master branch, we don't publish SNAPSHOT
artifacts for PRs - to not override SNAPSHOTS based on the master
branch. You can download the source [1] and build it yourself locally,
or you can download the artifacts built during PR build [2]

[1] https://github.com/lukaszlenart/struts/archive/localized-bean.zip
[2] https://builds.apache.org/view/S-Z/view/Struts/job/Struts-JDK7-pull-request/ws/


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localized bean

Greg Huber
So I would only need to replace the struts2-core.x.x.jar?

On 14 March 2017 at 10:14, Lukasz Lenart <[hidden email]> wrote:

> 2017-03-14 10:32 GMT+01:00 Greg Huber <[hidden email]>:
> > I remember there was a snapshot build from the trunk that I used to use
> to
> > monitor progress, is that still being built here?
>
> Yeah but only for the master branch, we don't publish SNAPSHOT
> artifacts for PRs - to not override SNAPSHOTS based on the master
> branch. You can download the source [1] and build it yourself locally,
> or you can download the artifacts built during PR build [2]
>
> [1] https://github.com/lukaszlenart/struts/archive/localized-bean.zip
> [2] https://builds.apache.org/view/S-Z/view/Struts/job/
> Struts-JDK7-pull-request/ws/
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localized bean

Lukasz Lenart
2017-03-14 15:03 GMT+01:00 Greg Huber <[hidden email]>:
> So I would only need to replace the struts2-core.x.x.jar?

Yes, you are right :)


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localized bean

Greg Huber
Initial tests look good.

LocalizedTextUtil.java is now the only bespoke mod I do (to check the
default ApplicationResources.properties first and then do the package nifty
thing).

I have looked in

Struts-JDK7-pull-request/core/src/main/java/com/opensymphony/xwork2/util

but seems not to be there has the package location changed?

I can see it here though https://github.com/lukaszlenart/struts/tree......

Cheers Greg


On 14 March 2017 at 14:14, Lukasz Lenart <[hidden email]> wrote:

> 2017-03-14 15:03 GMT+01:00 Greg Huber <[hidden email]>:
> > So I would only need to replace the struts2-core.x.x.jar?
>
> Yes, you are right :)
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localized bean

Lukasz Lenart
2017-03-14 15:24 GMT+01:00 Greg Huber <[hidden email]>:

> Initial tests look good.
>
> LocalizedTextUtil.java is now the only bespoke mod I do (to check the
> default ApplicationResources.properties first and then do the package nifty
> thing).
>
> I have looked in
>
> Struts-JDK7-pull-request/core/src/main/java/com/opensymphony/xwork2/util
>
> but seems not to be there has the package location changed?
>
> I can see it here though https://github.com/lukaszlenart/struts/tree......

There is no more static LocalizedTextUtil, this class it's a bean
right now called DefaultLocalizedTextProvider and implements
LocalizedTextProvider interface. You can gain access to it via @Inject
or via container.getInstance(LocalizedTextProvider.class)


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localized bean

Greg Huber
I replace:

// search up class hierarchy
String msg = findMessage(aClass, aTextName, indexedTextName,
         locale, args, null, valueStack);

with:

GetDefaultMessageReturnArg result = null;
        if (indexedTextName == null) {
            // Use a null for the defaultMessage to ensure
            // package check is done if not found. Will get dev messages if
            // not found in default packages.
            result = getDefaultMessage(aTextName, locale, valueStack, args,
                    null);
        }
        String msg = null;
        if (result == null) {
            // search up class hierarchy
            msg = findMessage(aClass, aTextName, indexedTextName, locale,
args,
                    null, valueStack);
        } else {
            msg = result.message;
        }

Guess I will have to continue this mod unless there is some way to override
the default search package nifty thing.

Cheers Greg

On 14 March 2017 at 14:27, Lukasz Lenart <[hidden email]> wrote:

> 2017-03-14 15:24 GMT+01:00 Greg Huber <[hidden email]>:
> > Initial tests look good.
> >
> > LocalizedTextUtil.java is now the only bespoke mod I do (to check the
> > default ApplicationResources.properties first and then do the package
> nifty
> > thing).
> >
> > I have looked in
> >
> > Struts-JDK7-pull-request/core/src/main/java/com/opensymphony/xwork2/util
> >
> > but seems not to be there has the package location changed?
> >
> > I can see it here though https://github.com/lukaszlenart/struts/tree....
> ..
>
> There is no more static LocalizedTextUtil, this class it's a bean
> right now called DefaultLocalizedTextProvider and implements
> LocalizedTextProvider interface. You can gain access to it via @Inject
> or via container.getInstance(LocalizedTextProvider.class)
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localized bean

Lukasz Lenart
2017-03-14 16:13 GMT+01:00 Greg Huber <[hidden email]>:

> I replace:
>
> // search up class hierarchy
> String msg = findMessage(aClass, aTextName, indexedTextName,
>          locale, args, null, valueStack);
>
> with:
>
> GetDefaultMessageReturnArg result = null;
>         if (indexedTextName == null) {
>             // Use a null for the defaultMessage to ensure
>             // package check is done if not found. Will get dev messages if
>             // not found in default packages.
>             result = getDefaultMessage(aTextName, locale, valueStack, args,
>                     null);
>         }
>         String msg = null;
>         if (result == null) {
>             // search up class hierarchy
>             msg = findMessage(aClass, aTextName, indexedTextName, locale,
> args,
>                     null, valueStack);
>         } else {
>             msg = result.message;
>         }
>
> Guess I will have to continue this mod unless there is some way to override
> the default search package nifty thing.

Hm... I think defining struts.custom.i18n.resources should resolve your problem

struts.custom.i18n.resources=ApplicationResources

Or you can implement your own LocalizedTextProvider and used instead
the one provided by the framework (when my gets merged :) Anyway I
think this is good to merge, we can think about improving it with
another PR.


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localized bean

Greg Huber
>Hm... I think defining struts.custom.i18n.resources should resolve your
problem
>struts.custom.i18n.resources=ApplicationResources

I already have this, but since I came from a struts 1, I am not motivated
to use the class package logic as there would be too much duplication and
maintenance of all the .properties files.

I do use package files for validation, just not the UI layer, so I still
need to do the nifty thing (all though I do get warning messages with the
modification doing the default first for these).

The package search is just too extensive as it looks at interfaces of the
classes etc and is too much of an overhead for busy screens.  Just the
package where the action class is should be enough?

Maybe it would be useful to have a method in DefaultLocalizedTextProvider
that only does the search/order so we could override it and implement our
own.

Cheers Greg




On 14 March 2017 at 18:24, Lukasz Lenart <[hidden email]> wrote:

> 2017-03-14 16:13 GMT+01:00 Greg Huber <[hidden email]>:
> > I replace:
> >
> > // search up class hierarchy
> > String msg = findMessage(aClass, aTextName, indexedTextName,
> >          locale, args, null, valueStack);
> >
> > with:
> >
> > GetDefaultMessageReturnArg result = null;
> >         if (indexedTextName == null) {
> >             // Use a null for the defaultMessage to ensure
> >             // package check is done if not found. Will get dev messages
> if
> >             // not found in default packages.
> >             result = getDefaultMessage(aTextName, locale, valueStack,
> args,
> >                     null);
> >         }
> >         String msg = null;
> >         if (result == null) {
> >             // search up class hierarchy
> >             msg = findMessage(aClass, aTextName, indexedTextName, locale,
> > args,
> >                     null, valueStack);
> >         } else {
> >             msg = result.message;
> >         }
> >
> > Guess I will have to continue this mod unless there is some way to
> override
> > the default search package nifty thing.
>
> Hm... I think defining struts.custom.i18n.resources should resolve your
> problem
>
> struts.custom.i18n.resources=ApplicationResources
>
> Or you can implement your own LocalizedTextProvider and used instead
> the one provided by the framework (when my gets merged :) Anyway I
> think this is good to merge, we can think about improving it with
> another PR.
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localized bean

lukaszlenart
Something like getDefaultText()? but you can always implement your own
LocalizedTextProvider and search in default bundles first and then
fallback to searching class hierarchy.

Maybe I should prepare a small demo?


Regards
--
Łukasz

2017-03-15 9:08 GMT+01:00 Greg Huber <[hidden email]>:

>>Hm... I think defining struts.custom.i18n.resources should resolve your
> problem
>>struts.custom.i18n.resources=ApplicationResources
>
> I already have this, but since I came from a struts 1, I am not motivated
> to use the class package logic as there would be too much duplication and
> maintenance of all the .properties files.
>
> I do use package files for validation, just not the UI layer, so I still
> need to do the nifty thing (all though I do get warning messages with the
> modification doing the default first for these).
>
> The package search is just too extensive as it looks at interfaces of the
> classes etc and is too much of an overhead for busy screens.  Just the
> package where the action class is should be enough?
>
> Maybe it would be useful to have a method in DefaultLocalizedTextProvider
> that only does the search/order so we could override it and implement our
> own.
>
> Cheers Greg
>
>
>
>
> On 14 March 2017 at 18:24, Lukasz Lenart <[hidden email]> wrote:
>
>> 2017-03-14 16:13 GMT+01:00 Greg Huber <[hidden email]>:
>> > I replace:
>> >
>> > // search up class hierarchy
>> > String msg = findMessage(aClass, aTextName, indexedTextName,
>> >          locale, args, null, valueStack);
>> >
>> > with:
>> >
>> > GetDefaultMessageReturnArg result = null;
>> >         if (indexedTextName == null) {
>> >             // Use a null for the defaultMessage to ensure
>> >             // package check is done if not found. Will get dev messages
>> if
>> >             // not found in default packages.
>> >             result = getDefaultMessage(aTextName, locale, valueStack,
>> args,
>> >                     null);
>> >         }
>> >         String msg = null;
>> >         if (result == null) {
>> >             // search up class hierarchy
>> >             msg = findMessage(aClass, aTextName, indexedTextName, locale,
>> > args,
>> >                     null, valueStack);
>> >         } else {
>> >             msg = result.message;
>> >         }
>> >
>> > Guess I will have to continue this mod unless there is some way to
>> override
>> > the default search package nifty thing.
>>
>> Hm... I think defining struts.custom.i18n.resources should resolve your
>> problem
>>
>> struts.custom.i18n.resources=ApplicationResources
>>
>> Or you can implement your own LocalizedTextProvider and used instead
>> the one provided by the framework (when my gets merged :) Anyway I
>> think this is good to merge, we can think about improving it with
>> another PR.
>>
>>
>> Regards
>> --
>> Łukasz
>> + 48 606 323 122 http://www.lenart.org.pl/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localized bean

Greg Huber
 >you can always implement your own
>LocalizedTextProvider and search in default bundles first and then
>fallback to searching class hierarchy.

There seems alot going on in DefaultLocalizedTextProvider so I would rather
stay with the default and do the local modification.

>Something like getDefaultText()

It would mean refractoring the code slightly, not sure what other users
would want, but I remember an email a while back on the same thing, ie only
using the default package of the class rather than all the interfaces etc.
Maybe class package, default then scan the interfaces (nifty thing)?

>Maybe I should prepare a small demo?

Maybe give us an idea of how to use the bean.

Cheers Greg


On 15 March 2017 at 08:32, Łukasz Lenart <[hidden email]> wrote:

> Something like getDefaultText()? but you can always implement your own
> LocalizedTextProvider and search in default bundles first and then
> fallback to searching class hierarchy.
>
> Maybe I should prepare a small demo?
>
>
> Regards
> --
> Łukasz
>
> 2017-03-15 9:08 GMT+01:00 Greg Huber <[hidden email]>:
> >>Hm... I think defining struts.custom.i18n.resources should resolve your
> > problem
> >>struts.custom.i18n.resources=ApplicationResources
> >
> > I already have this, but since I came from a struts 1, I am not motivated
> > to use the class package logic as there would be too much duplication and
> > maintenance of all the .properties files.
> >
> > I do use package files for validation, just not the UI layer, so I still
> > need to do the nifty thing (all though I do get warning messages with the
> > modification doing the default first for these).
> >
> > The package search is just too extensive as it looks at interfaces of the
> > classes etc and is too much of an overhead for busy screens.  Just the
> > package where the action class is should be enough?
> >
> > Maybe it would be useful to have a method in DefaultLocalizedTextProvider
> > that only does the search/order so we could override it and implement our
> > own.
> >
> > Cheers Greg
> >
> >
> >
> >
> > On 14 March 2017 at 18:24, Lukasz Lenart <[hidden email]>
> wrote:
> >
> >> 2017-03-14 16:13 GMT+01:00 Greg Huber <[hidden email]>:
> >> > I replace:
> >> >
> >> > // search up class hierarchy
> >> > String msg = findMessage(aClass, aTextName, indexedTextName,
> >> >          locale, args, null, valueStack);
> >> >
> >> > with:
> >> >
> >> > GetDefaultMessageReturnArg result = null;
> >> >         if (indexedTextName == null) {
> >> >             // Use a null for the defaultMessage to ensure
> >> >             // package check is done if not found. Will get dev
> messages
> >> if
> >> >             // not found in default packages.
> >> >             result = getDefaultMessage(aTextName, locale, valueStack,
> >> args,
> >> >                     null);
> >> >         }
> >> >         String msg = null;
> >> >         if (result == null) {
> >> >             // search up class hierarchy
> >> >             msg = findMessage(aClass, aTextName, indexedTextName,
> locale,
> >> > args,
> >> >                     null, valueStack);
> >> >         } else {
> >> >             msg = result.message;
> >> >         }
> >> >
> >> > Guess I will have to continue this mod unless there is some way to
> >> override
> >> > the default search package nifty thing.
> >>
> >> Hm... I think defining struts.custom.i18n.resources should resolve your
> >> problem
> >>
> >> struts.custom.i18n.resources=ApplicationResources
> >>
> >> Or you can implement your own LocalizedTextProvider and used instead
> >> the one provided by the framework (when my gets merged :) Anyway I
> >> think this is good to merge, we can think about improving it with
> >> another PR.
> >>
> >>
> >> Regards
> >> --
> >> Łukasz
> >> + 48 606 323 122 http://www.lenart.org.pl/
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localized bean

Lukasz Lenart
2017-03-15 9:50 GMT+01:00 Greg Huber <[hidden email]>:
>>you can always implement your own
>>LocalizedTextProvider and search in default bundles first and then
>>fallback to searching class hierarchy.
>
> There seems alot going on in DefaultLocalizedTextProvider so I would rather
> stay with the default and do the local modification.

Right :) I hope with converting this class into a bean it will be
possible to simplify things ;-)

>>Something like getDefaultText()
>
> It would mean refractoring the code slightly, not sure what other users
> would want, but I remember an email a while back on the same thing, ie only
> using the default package of the class rather than all the interfaces etc.
> Maybe class package, default then scan the interfaces (nifty thing)?

It is possible, I mean adding another simplified implementation which
only uses classes without scanning the class hierarchy. Could you
register a ticket for that?

>>Maybe I should prepare a small demo?
>
> Maybe give us an idea of how to use the bean.

Sure, I will prepare one :)


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localized bean

Greg Huber
Would this be enough information?

https://issues.apache.org/jira/browse/WW-4762

Cheers Greg

On 17 March 2017 at 07:16, Lukasz Lenart <[hidden email]> wrote:

> 2017-03-15 9:50 GMT+01:00 Greg Huber <[hidden email]>:
> >>you can always implement your own
> >>LocalizedTextProvider and search in default bundles first and then
> >>fallback to searching class hierarchy.
> >
> > There seems alot going on in DefaultLocalizedTextProvider so I would
> rather
> > stay with the default and do the local modification.
>
> Right :) I hope with converting this class into a bean it will be
> possible to simplify things ;-)
>
> >>Something like getDefaultText()
> >
> > It would mean refractoring the code slightly, not sure what other users
> > would want, but I remember an email a while back on the same thing, ie
> only
> > using the default package of the class rather than all the interfaces
> etc.
> > Maybe class package, default then scan the interfaces (nifty thing)?
>
> It is possible, I mean adding another simplified implementation which
> only uses classes without scanning the class hierarchy. Could you
> register a ticket for that?
>
> >>Maybe I should prepare a small demo?
> >
> > Maybe give us an idea of how to use the bean.
>
> Sure, I will prepare one :)
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localized bean

Lukasz Lenart
Looks good, thanks :)

2017-03-17 12:05 GMT+01:00 Greg Huber <[hidden email]>:

> Would this be enough information?
>
> https://issues.apache.org/jira/browse/WW-4762
>
> Cheers Greg
>
> On 17 March 2017 at 07:16, Lukasz Lenart <[hidden email]> wrote:
>
>> 2017-03-15 9:50 GMT+01:00 Greg Huber <[hidden email]>:
>> >>you can always implement your own
>> >>LocalizedTextProvider and search in default bundles first and then
>> >>fallback to searching class hierarchy.
>> >
>> > There seems alot going on in DefaultLocalizedTextProvider so I would
>> rather
>> > stay with the default and do the local modification.
>>
>> Right :) I hope with converting this class into a bean it will be
>> possible to simplify things ;-)
>>
>> >>Something like getDefaultText()
>> >
>> > It would mean refractoring the code slightly, not sure what other users
>> > would want, but I remember an email a while back on the same thing, ie
>> only
>> > using the default package of the class rather than all the interfaces
>> etc.
>> > Maybe class package, default then scan the interfaces (nifty thing)?
>>
>> It is possible, I mean adding another simplified implementation which
>> only uses classes without scanning the class hierarchy. Could you
>> register a ticket for that?
>>
>> >>Maybe I should prepare a small demo?
>> >
>> > Maybe give us an idea of how to use the bean.
>>
>> Sure, I will prepare one :)
>>
>>
>> Regards
>> --
>> Łukasz
>> + 48 606 323 122 http://www.lenart.org.pl/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localized bean

Lukasz Lenart
I have an example app ready but to get it merged into struts-examples,
this PR must get merged first [1]

[1] https://github.com/apache/struts/pull/123


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Localized bean

Lukasz Lenart
The got merged so the example is in as well :)

2017-03-22 7:45 GMT+01:00 Lukasz Lenart <[hidden email]>:

> I have an example app ready but to get it merged into struts-examples,
> this PR must get merged first [1]
>
> [1] https://github.com/apache/struts/pull/123
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...