Single quotes in text for SimpleError message disappear

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Single quotes in text for SimpleError message disappear

Thomas Jespersen-2
Hi,

I recently ran into a problem with SimpleError, where it removed all single
quotes from my message string, when given no arguments. I use SimpleError
something like this:

new SimpleError("Error: Element 'foo' not found", new Object[0])

But the _actual_ message printed, is: "Error: Element foo not found"

Reading into it I found a similar issue addressed in release 1.5.5:

http://sourceforge.net/projects/stripes/files/stripes/Stripes%201.5.5/

but we use 1.5.7, so it should be fine. I also found:

http://www.stripesframework.org/jira/browse/STS-789

which addressed the problem of SimpleMessage using MessageFormat when there were
no replacement parameters. And SimpleError extends SimpleMessage, so why didn't
it work?

Well, the SimpleError constructor widens the parameter list to make room for two
standard parameters (field name and field value), so the check in
SimpleMessage#getMessage _always_ succeeds when using SimpleError (it checks
that the number of replacement parameters is greater than zero), and thus my
single quotes got removed.

My immediate fix has been to replace all single quotes by two single quotes,
which works for my purposes, but it feels hacky. And I have the idea that
SimpleError should work similarly to SimpleMessage (since it extends it), so I
thought I'd post my findings here. Is this something that needs to be fixed, or
am I doing something wrong?

Suggestions, ideas and comments are welcome! Thanks :-)

-- Thomas


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Single quotes in text for SimpleError message disappear

Mike McNally-3
That's not Stripes, it's the basic Java message system.  Use two single quotes instead of just one in order to include a single quote in your message text.

On Thu, Jan 24, 2013 at 10:09 AM, Thomas Jespersen <[hidden email]> wrote:
Hi,

I recently ran into a problem with SimpleError, where it removed all single
quotes from my message string, when given no arguments. I use SimpleError
something like this:

new SimpleError("Error: Element 'foo' not found", new Object[0])

But the _actual_ message printed, is: "Error: Element foo not found"

Reading into it I found a similar issue addressed in release 1.5.5:

http://sourceforge.net/projects/stripes/files/stripes/Stripes%201.5.5/

but we use 1.5.7, so it should be fine. I also found:

http://www.stripesframework.org/jira/browse/STS-789

which addressed the problem of SimpleMessage using MessageFormat when there were
no replacement parameters. And SimpleError extends SimpleMessage, so why didn't
it work?

Well, the SimpleError constructor widens the parameter list to make room for two
standard parameters (field name and field value), so the check in
SimpleMessage#getMessage _always_ succeeds when using SimpleError (it checks
that the number of replacement parameters is greater than zero), and thus my
single quotes got removed.

My immediate fix has been to replace all single quotes by two single quotes,
which works for my purposes, but it feels hacky. And I have the idea that
SimpleError should work similarly to SimpleMessage (since it extends it), so I
thought I'd post my findings here. Is this something that needs to be fixed, or
am I doing something wrong?

Suggestions, ideas and comments are welcome! Thanks :-)

-- Thomas


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



--
Turtle, turtle, on the ground,
Pink and shiny, turn around.
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Single quotes in text for SimpleError message disappear

Mike McNally-3
sorry I need more coffee I guess :-)

On Thu, Jan 24, 2013 at 10:18 AM, Mike McNally <[hidden email]> wrote:
That's not Stripes, it's the basic Java message system.  Use two single quotes instead of just one in order to include a single quote in your message text.


On Thu, Jan 24, 2013 at 10:09 AM, Thomas Jespersen <[hidden email]> wrote:
Hi,

I recently ran into a problem with SimpleError, where it removed all single
quotes from my message string, when given no arguments. I use SimpleError
something like this:

new SimpleError("Error: Element 'foo' not found", new Object[0])

But the _actual_ message printed, is: "Error: Element foo not found"

Reading into it I found a similar issue addressed in release 1.5.5:

http://sourceforge.net/projects/stripes/files/stripes/Stripes%201.5.5/

but we use 1.5.7, so it should be fine. I also found:

http://www.stripesframework.org/jira/browse/STS-789

which addressed the problem of SimpleMessage using MessageFormat when there were
no replacement parameters. And SimpleError extends SimpleMessage, so why didn't
it work?

Well, the SimpleError constructor widens the parameter list to make room for two
standard parameters (field name and field value), so the check in
SimpleMessage#getMessage _always_ succeeds when using SimpleError (it checks
that the number of replacement parameters is greater than zero), and thus my
single quotes got removed.

My immediate fix has been to replace all single quotes by two single quotes,
which works for my purposes, but it feels hacky. And I have the idea that
SimpleError should work similarly to SimpleMessage (since it extends it), so I
thought I'd post my findings here. Is this something that needs to be fixed, or
am I doing something wrong?

Suggestions, ideas and comments are welcome! Thanks :-)

-- Thomas


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



--
Turtle, turtle, on the ground,
Pink and shiny, turn around.



--
Turtle, turtle, on the ground,
Pink and shiny, turn around.
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Single quotes in text for SimpleError message disappear

Mike McNally-3
The fix for the bug you mention applies to SimpleMessage.  The SimpleError constructor always extends the parameter list by 2 to make room for the two standard parameters always passed in for errors.


On Thu, Jan 24, 2013 at 10:19 AM, Mike McNally <[hidden email]> wrote:
sorry I need more coffee I guess :-)


On Thu, Jan 24, 2013 at 10:18 AM, Mike McNally <[hidden email]> wrote:
That's not Stripes, it's the basic Java message system.  Use two single quotes instead of just one in order to include a single quote in your message text.


On Thu, Jan 24, 2013 at 10:09 AM, Thomas Jespersen <[hidden email]> wrote:
Hi,

I recently ran into a problem with SimpleError, where it removed all single
quotes from my message string, when given no arguments. I use SimpleError
something like this:

new SimpleError("Error: Element 'foo' not found", new Object[0])

But the _actual_ message printed, is: "Error: Element foo not found"

Reading into it I found a similar issue addressed in release 1.5.5:

http://sourceforge.net/projects/stripes/files/stripes/Stripes%201.5.5/

but we use 1.5.7, so it should be fine. I also found:

http://www.stripesframework.org/jira/browse/STS-789

which addressed the problem of SimpleMessage using MessageFormat when there were
no replacement parameters. And SimpleError extends SimpleMessage, so why didn't
it work?

Well, the SimpleError constructor widens the parameter list to make room for two
standard parameters (field name and field value), so the check in
SimpleMessage#getMessage _always_ succeeds when using SimpleError (it checks
that the number of replacement parameters is greater than zero), and thus my
single quotes got removed.

My immediate fix has been to replace all single quotes by two single quotes,
which works for my purposes, but it feels hacky. And I have the idea that
SimpleError should work similarly to SimpleMessage (since it extends it), so I
thought I'd post my findings here. Is this something that needs to be fixed, or
am I doing something wrong?

Suggestions, ideas and comments are welcome! Thanks :-)

-- Thomas


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



--
Turtle, turtle, on the ground,
Pink and shiny, turn around.



--
Turtle, turtle, on the ground,
Pink and shiny, turn around.



--
Turtle, turtle, on the ground,
Pink and shiny, turn around.
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Single quotes in text for SimpleError message disappear

Thomas Jespersen-2
Mike McNally <emmecinque@...> writes:

Hi Mike,

>
>
> The fix for the bug you mention applies to SimpleMessage.  The SimpleError
constructor always extends the parameter list by 2 to make room for the two
standard parameters always passed in for errors.

Thanks for your replies :-) This is as far as I got as well, but I was wondering
if SimpleError shouldn't avoid using MessageFormat as well if there are no
replacement parameters? Or, should it in fact _always_ use MessageFormat on
account of the standard parameters?

Thanks again!

-- Thomas

>
> On Thu, Jan 24, 2013 at 10:19 AM, Mike McNally
<[hidden email]> wrote:
> sorry I need more coffee I guess
> On Thu, Jan 24, 2013 at 10:18 AM, Mike McNally
<[hidden email]> wrote:That's not Stripes,
it's the basic Java message system.  Use two single quotes instead of just one
in order to include a single quote in your message text.
>
>
> On Thu, Jan 24, 2013 at 10:09 AM, Thomas Jespersen
<[hidden email]> wrote:Hi,
> I recently ran into a problem with SimpleError, where it removed all single
> quotes from my message string, when given no arguments. I use SimpleError
> something like this:
> new SimpleError("Error: Element 'foo' not found", new Object[0])
> But the _actual_ message printed, is: "Error: Element foo not found"
> Reading into it I found a similar issue addressed in release
1.5.5:http://sourceforge.net/projects/stripes/files/stripes/Stripes%201.5.5/
> but we use 1.5.7, so it should be fine. I also
found:http://www.stripesframework.org/jira/browse/STS-789

> which addressed the problem of SimpleMessage using MessageFormat when there
> were no replacement parameters. And SimpleError extends SimpleMessage, so why
> didn't it work?
> Well, the SimpleError constructor widens the parameter list to make room for
> two standard parameters (field name and field value), so the check in
> SimpleMessage#getMessage _always_ succeeds when using SimpleError (it checks
> that the number of replacement parameters is greater than zero), and thus my
> single quotes got removed.
> My immediate fix has been to replace all single quotes by two single quotes,
> which works for my purposes, but it feels hacky. And I have the idea that
> SimpleError should work similarly to SimpleMessage (since it extends it), so I
> thought I'd post my findings here. Is this something that needs to be fixed,
> or am I doing something wrong?
> Suggestions, ideas and comments are welcome! Thanks





------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Single quotes in text for SimpleError message disappear

Mike McNally-3
Thanks for your replies :-) This is as far as I got as well, but I was wondering
if SimpleError shouldn't avoid using MessageFormat as well if there are no
replacement parameters? Or, should it in fact _always_ use MessageFormat on
account of the standard parameters?

Well because the code doesn't pay any attention to the message string itself (which makes sense), and because Stripes error messages always include the offending field name and field value parameters, I think it's safe to assume that all messages used for errors will be treated as requiring a pass through MessageFormat.
 
--
Turtle, turtle, on the ground,
Pink and shiny, turn around.
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users