You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Greg Huber <gr...@gmail.com> on 2016/10/12 08:03:16 UTC
HttpParametersAware
I have tested this and looks OK.
.....I have an action that implements HttpParametersAware so I can use the
properties from the request eg:
public void setParameters(HttpParameters parameters) {
this.params = parameters.toMap();
}
private String getParameter(String key) {
String[] p = (String[]) this.params.get(key);
if (p != null && p.length > 0) {
return p[0];
}
return null;
}
In my db, I have a properties file with key=site.description, value='
My Site Description.'
On my config form, I have a field with the name of site.description which
is a key and is a string (ie not getSite().getDescription()) eg:
<input id="config_site_description" type="text" value="My Site Description."
size="35" name="site.description">
When I submit the form com.opensymphony.xwork2.util.ValueStack#setValue(..)
tries to evaluate it to the bean.property rather than the string and throws
an exception. In DEV mode I get messages like:
Error setting expression 'site.description' with value 'My Site Description.
'
I get a whole load of these as its my main config page, one for every
config value.
I guess there is no way to suppress these messages in dev mode?
Cheers
Re: HttpParametersAware
Posted by Lukasz Lenart <lu...@apache.org>.
You can try setting
<constant name="struts.ognl.logMissingProperties" value="false"/>
2016-10-12 10:03 GMT+02:00 Greg Huber <gr...@gmail.com>:
> I have tested this and looks OK.
>
> .....I have an action that implements HttpParametersAware so I can use the
> properties from the request eg:
>
> public void setParameters(HttpParameters parameters) {
> this.params = parameters.toMap();
> }
> private String getParameter(String key) {
> String[] p = (String[]) this.params.get(key);
> if (p != null && p.length > 0) {
> return p[0];
> }
> return null;
> }
>
> In my db, I have a properties file with key=site.description, value='
> My Site Description.'
>
> On my config form, I have a field with the name of site.description which
> is a key and is a string (ie not getSite().getDescription()) eg:
>
> <input id="config_site_description" type="text" value="My Site Description."
> size="35" name="site.description">
>
> When I submit the form com.opensymphony.xwork2.util.ValueStack#setValue(..)
> tries to evaluate it to the bean.property rather than the string and throws
> an exception. In DEV mode I get messages like:
>
> Error setting expression 'site.description' with value 'My Site Description.
> '
>
> I get a whole load of these as its my main config page, one for every
> config value.
>
> I guess there is no way to suppress these messages in dev mode?
>
> Cheers
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org
Re: HttpParametersAware
Posted by Greg Huber <gr...@gmail.com>.
I think as a work around I can call setActionMessages(null); before I start
my action, which removes these messages just for this case.
On 12 October 2016 at 09:03, Greg Huber <gr...@gmail.com> wrote:
> I have tested this and looks OK.
>
> .....I have an action that implements HttpParametersAware so I can use the
> properties from the request eg:
>
> public void setParameters(HttpParameters parameters) {
> this.params = parameters.toMap();
> }
> private String getParameter(String key) {
> String[] p = (String[]) this.params.get(key);
> if (p != null && p.length > 0) {
> return p[0];
> }
> return null;
> }
>
> In my db, I have a properties file with key=site.description, value='
> My Site Description.'
>
> On my config form, I have a field with the name of site.description which
> is a key and is a string (ie not getSite().getDescription()) eg:
>
> <input id="config_site_description" type="text" value="My Site
> Description." size="35" name="site.description">
>
> When I submit the form com.opensymphony.xwork2.util.ValueStack#setValue(..)
> tries to evaluate it to the bean.property rather than the string and throws
> an exception. In DEV mode I get messages like:
>
> Error setting expression 'site.description' with value 'My Site
> Description.'
>
> I get a whole load of these as its my main config page, one for every
> config value.
>
> I guess there is no way to suppress these messages in dev mode?
>
> Cheers
>
>
>
>