You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ManiKanta G <go...@gmail.com> on 2009/02/27 08:37:47 UTC
S2 REST xml de-serialization
Hi,
I m writing a REST service in S2 (using REST plugin) to store the data
received through xml snippet. But I m struck with the default behavior of
the plugin
<?xml version="1.0" encoding="UTF-8"?>
<books xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xforms="
http://www.w3.org/2002/xforms" xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xxforms="
http://orbeon.org/oxf/xml/xforms">
<book>
<title>Harry Potter</title>
<author>J. K. Rowling</author>
<language>en</language>
<rating>5</rating>
<notes>Story of a wizard kid</notes>
</book>
But when using REST default de-serialization, the <book> root node should
have fully qualified package name of the class. But in my case it is not
possible as I m getting only <book> (in fact as I m using Orbeon forms, the
instance will be submitted to the service in the above format).
Is it possible to alter that behavior?
Thanks,
ManiKanta G
Twitter/manikantag
RE: String manipulation
Posted by Richard Gundersen <R....@salford.ac.uk>.
Thanks David. I've just got it working actually, I missed out a bracket
in my original solution, so the syntax should be
@FieldExpressionValidator(expression="(accountFileFileName.endsWith('.cs
v'))", message="", key="validate.invalidFilename",
fieldName="accountFileFileName")
Silly mistake I know. If I run into any more problems with it though
I'll use your suggestion - thanks
-----Original Message-----
From: David Harland [mailto:harlander3000@yahoo.com]
Sent: 27 February 2009 11:04
To: Struts Users Mailing List
Subject: RE: String manipulation
Try adding this to your action
static final Pattern pattern = Pattern.compile("^.+\\.((csv)|(xls))$",
Pattern.CASE_INSENSITIVE);
In your validateUpload method have something like
Matcher matcher = pattern.matcher(fileName);
if (!matcher.matches()) {
addActionError("File type not allowed");
return;
}
Remove |(xls) if you dont want to allow xls files
--- On Fri, 2/27/09, Richard Gundersen <R....@salford.ac.uk>
wrote:
> From: Richard Gundersen <R....@salford.ac.uk>
> Subject: RE: String manipulation
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Date: Friday, February 27, 2009, 11:50 AM
> Hmmm, no that also prevents genuine csv files from being
> selected too.
>
> Also investigating the accept attribute on the s:file tag
> to see if that
> will help...
>
> Any help appreciated.
>
> -----Original Message-----
> From: Richard Gundersen [mailto:R.Gundersen@salford.ac.uk]
> Sent: 27 February 2009 10:27
> To: Struts Users Mailing List
> Subject: RE: String manipulation
>
> Oh, got it
>
>
@FieldExpressionValidator(expression="(accountFileFileName.endsWith('.cs
> v')", message="",
> key="validate.invalidFilename",
> fieldName="accountFileFileName")
>
> Forgot you could just call methods in OGNL :)
>
> -Richard
>
> -----Original Message-----
> From: Richard Gundersen [mailto:R.Gundersen@salford.ac.uk]
> Sent: 27 February 2009 10:16
> To: Struts Users Mailing List
> Subject: String manipulation
>
> Hi
>
> I'm trying to validate that a filename has a .csv
> extension. I would
> like to use @FieldExpressionValidator on the field but I
> can't get the
> syntax right, and searching the docs I can't find much
> on String
> manipulation in OGNL.
>
> Could anyone help me out please?
>
> Thanks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: String manipulation
Posted by David Harland <ha...@yahoo.com>.
Try adding this to your action
static final Pattern pattern = Pattern.compile("^.+\\.((csv)|(xls))$", Pattern.CASE_INSENSITIVE);
In your validateUpload method have something like
Matcher matcher = pattern.matcher(fileName);
if (!matcher.matches()) {
addActionError("File type not allowed");
return;
}
Remove |(xls) if you dont want to allow xls files
--- On Fri, 2/27/09, Richard Gundersen <R....@salford.ac.uk> wrote:
> From: Richard Gundersen <R....@salford.ac.uk>
> Subject: RE: String manipulation
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Date: Friday, February 27, 2009, 11:50 AM
> Hmmm, no that also prevents genuine csv files from being
> selected too.
>
> Also investigating the accept attribute on the s:file tag
> to see if that
> will help...
>
> Any help appreciated.
>
> -----Original Message-----
> From: Richard Gundersen [mailto:R.Gundersen@salford.ac.uk]
> Sent: 27 February 2009 10:27
> To: Struts Users Mailing List
> Subject: RE: String manipulation
>
> Oh, got it
>
> @FieldExpressionValidator(expression="(accountFileFileName.endsWith('.cs
> v')", message="",
> key="validate.invalidFilename",
> fieldName="accountFileFileName")
>
> Forgot you could just call methods in OGNL :)
>
> -Richard
>
> -----Original Message-----
> From: Richard Gundersen [mailto:R.Gundersen@salford.ac.uk]
> Sent: 27 February 2009 10:16
> To: Struts Users Mailing List
> Subject: String manipulation
>
> Hi
>
> I'm trying to validate that a filename has a .csv
> extension. I would
> like to use @FieldExpressionValidator on the field but I
> can't get the
> syntax right, and searching the docs I can't find much
> on String
> manipulation in OGNL.
>
> Could anyone help me out please?
>
> Thanks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: String manipulation
Posted by Richard Gundersen <R....@salford.ac.uk>.
Hmmm, no that also prevents genuine csv files from being selected too.
Also investigating the accept attribute on the s:file tag to see if that
will help...
Any help appreciated.
-----Original Message-----
From: Richard Gundersen [mailto:R.Gundersen@salford.ac.uk]
Sent: 27 February 2009 10:27
To: Struts Users Mailing List
Subject: RE: String manipulation
Oh, got it
@FieldExpressionValidator(expression="(accountFileFileName.endsWith('.cs
v')", message="", key="validate.invalidFilename",
fieldName="accountFileFileName")
Forgot you could just call methods in OGNL :)
-Richard
-----Original Message-----
From: Richard Gundersen [mailto:R.Gundersen@salford.ac.uk]
Sent: 27 February 2009 10:16
To: Struts Users Mailing List
Subject: String manipulation
Hi
I'm trying to validate that a filename has a .csv extension. I would
like to use @FieldExpressionValidator on the field but I can't get the
syntax right, and searching the docs I can't find much on String
manipulation in OGNL.
Could anyone help me out please?
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: String manipulation
Posted by Richard Gundersen <R....@salford.ac.uk>.
Oh, got it
@FieldExpressionValidator(expression="(accountFileFileName.endsWith('.cs
v')", message="", key="validate.invalidFilename",
fieldName="accountFileFileName")
Forgot you could just call methods in OGNL :)
-Richard
-----Original Message-----
From: Richard Gundersen [mailto:R.Gundersen@salford.ac.uk]
Sent: 27 February 2009 10:16
To: Struts Users Mailing List
Subject: String manipulation
Hi
I'm trying to validate that a filename has a .csv extension. I would
like to use @FieldExpressionValidator on the field but I can't get the
syntax right, and searching the docs I can't find much on String
manipulation in OGNL.
Could anyone help me out please?
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
String manipulation
Posted by Richard Gundersen <R....@salford.ac.uk>.
Hi
I'm trying to validate that a filename has a .csv extension. I would
like to use @FieldExpressionValidator on the field but I can't get the
syntax right, and searching the docs I can't find much on String
manipulation in OGNL.
Could anyone help me out please?
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org