Java Mailing List Archive

http://www.gg3721.com/

Home » Struts Users Mailing List »

user Digest 14 Jul 2008 10:04:03 -0000 Issue 8138

user-digest-help

2008-07-14


Author LoginPost Reply

user Digest 14 Jul 2008 10:04:03 -0000 Issue 8138

Topics (messages 188798 through 188827):

Referring to Properties object via OGNL?
 188798 by: Dave Belfer-Shevett
 188802 by: Gabriel Belingueres
 188803 by: Dave Belfer-Shevett
 188804 by: Dave Belfer-Shevett
 188806 by: Jeromy Evans

Re: [S2] action mapping with merely default action
 188799 by: Dave Newton
 188800 by: Dave Newton
 188801 by: Pierre Thibaudeau
 188805 by: Jeromy Evans

[S2] current URL in ValueStack?
 188807 by: Pierre Thibaudeau
 188808 by: Jeromy Evans
 188809 by: Pierre Thibaudeau
 188812 by: Jeromy Evans
 188815 by: Pierre Thibaudeau

Re: Customizing CSS
 188810 by: Narayana S
 188817 by: Jishnu Viswanath
 188825 by: Narayana S
 188827 by: Jishnu Viswanath

Re: [S2] Recipe for Action and View
 188811 by: ravi_eze

Extending Struts Controls - problem
 188813 by: Narayana S

Re: problem with checkbox (when using disabled property)
 188814 by: ravi_eze

struts2 validation
 188816 by: Nicole Luneburg
 188818 by: Jeromy Evans
 188820 by: Markus Stauffer
 188821 by: Nicole Luneburg
 188822 by: Markus Stauffer

struts menu problem
 188819 by: nauke.

REST and JSON plugins
 188823 by: Oleg Mikheev
 188824 by: Jeromy Evans

Re: about security
 188826 by: hns

Administrivia:

---------------------------------------------------------------------
To post to the list, e-mail: user@(protected)
To unsubscribe, e-mail: user-digest-unsubscribe@(protected)
For additional commands, e-mail: user-digest-help@(protected)

----------------------------------------------------------------------

Attachment: user_188798.ezm (zipped)
I have a situateion where I'm loading application specific settings via a
Properties object on initialization. I'm storing the Properties object up
into the ApplicationMap (heck it could be in the SessionMap, I'm easy),
but i can't seem to switch JSP behaviour based on information in the
Properties map.

I'm wondering if this is because Properties isn't exactly a HashMap, so
the #attr.mapname.somekey isn't working.

If I have a Properties object called 'props' in the SessionMap (or
anywhere on the stack actually), I should be able to get to it via #attr -
what's the proper syntax?

Java-wise, it's

Property p = new Properties;
String value = p.getProperty("somekey")

but naturally I don't want to do this in a scriptlet.

Help?

--
-------------------.--------.-------------------------------.
Dave Belfer-Shevett \ KB1FWR \ JID: dbs@(protected) \
blog:planet-geek.com >--------'-----------------------------------.
dbs@(protected) \
-------------------<  your development team: 3) "This code is a   |
            |     piece of crap! You have no honor!"     |
             \______________________________________________/


Attachment: user_188802.ezm (zipped)
Properties implements the Map interface, so AFAIK, it should work
accessing it as a Map.

Did you tried #attr.mapname[somekey]?

2008/7/13 Dave Belfer-Shevett <dbs@(protected)>:
> I have a situateion where I'm loading application specific settings via a
> Properties object on initialization. I'm storing the Properties object up
> into the ApplicationMap (heck it could be in the SessionMap, I'm easy), but
> i can't seem to switch JSP behaviour based on information in the Properties
> map.
>
> I'm wondering if this is because Properties isn't exactly a HashMap, so the
> #attr.mapname.somekey isn't working.
>
> If I have a Properties object called 'props' in the SessionMap (or anywhere
> on the stack actually), I should be able to get to it via #attr - what's the
> proper syntax?
>
> Java-wise, it's
>
> Property p = new Properties;
> String value = p.getProperty("somekey")
>
> but naturally I don't want to do this in a scriptlet.
>
> Help?
>
> --
> -------------------.--------.-------------------------------.
> Dave Belfer-Shevett \ KB1FWR \ JID: dbs@(protected) \
> blog:planet-geek.com >--------'-----------------------------------.
> dbs@(protected) \
> -------------------<  your development team: 3) "This code is a   |
>             |     piece of crap! You have no honor!"     |
>             \______________________________________________/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

Attachment: user_188803.ezm (zipped)
On Sun, 13 Jul 2008, Martin Gainty wrote:
> access it with
> <%
> ValueStack stack = getStack();
> stack.findValue("#attr.someKey");
> %>
> http://www.docjar.com/docs/api/java/util/Stack.html
>
> where you put the value.. HashSet,HashMap or Property is up to you..

Doesn't this violate the 'scriptlets are bad' concept?

 -dbs

Attachment: user_188804.ezm (zipped)
On Sun, 13 Jul 2008, Gabriel Belingueres wrote:
> Properties implements the Map interface, so AFAIK, it should work
> accessing it as a Map.
>
> Did you tried #attr.mapname[somekey]?

Yes...

I have an interceptor that does:

applicationMap = invocation.getInvocationContext().getApplication();
applicationMap.put("properties",props);
logger.debug("Props loaded: " + props.toString());

(when run, this sez:
2008-07-12 23:18:37,828 DEBUG
com.stonekeep.congo.interceptors.DBInterceptor:138 - Props loaded:
{preferredcid=2008}

In my JSP, I have:
Preferred cid is <s:property value="#attr.properties[preferredcid]"/><br>

Which, when rendered:
Pddreferred cid is

(with nothing after it)

The entire interceptor that is loading up the properties file and
publishing it into the ApplicationMap is here:

http://pastebin.stonekeep.com/4949

I may be missing something painfully obvious, but... help?

 -d

--
-------------------.--------.-------------------------------.
Dave Belfer-Shevett \ KB1FWR \ JID: dbs@(protected) \
blog:planet-geek.com >--------'-----------------------------------.
dbs@(protected)   \
-------------------<     List; Please Wait For Next Error     |
             \______________________________________________/

Attachment: user_188806.ezm (zipped)
Dave Belfer-Shevett wrote:
>
>
> In my JSP, I have:
> Preferred cid is <s:property value="#attr.properties[preferredcid]"/><br>
>
> Which, when rendered:
> Pddreferred cid is
>
> (with nothing after it)

This expression reads "evaluate perferredcid, then get the value of
#attr.properties[evalresult]".

I expect you want. <s:property value="#attr.properties['preferredcid']"/>

so it uses the literal string 'preferredcid' instead of evaluating it.

Please let me know if that fixes it. OGNL doesn't provide much useful
feedback for cases like these.






Attachment: user_188799.ezm (zipped)
--- On Sun, 7/13/08, Pierre Thibaudeau wrote:
> [S1] <action path="/home" forward="/static/home.jsp" />
>
> [S2]
> <action name="home" class="com.opensymphony.xwork2.ActionSupport">
>  <result>/static/home.jsp</result>
> </action>

If you're intent on using XML configuration, leave out the class.

> <action name="home">
>  <result>/static/home.jsp</result>
> </action>

Dave


Attachment: user_188800.ezm (zipped)
(Whoops; wrong button.)

Depending on how your application is laid out you could also put a "catch-all" mapping at the end of your regular mappings, like so:

<action name="*">
<result>/static/{1}.jsp</result>
</action>

Again, this is if you're intent on using XML configuration.

Dave

--- On Sun, 7/13/08, Pierre Thibaudeau <pierre.thibaudeau@(protected):

> From: Pierre Thibaudeau <pierre.thibaudeau@(protected)>
> Subject: [S2] action mapping with merely default action
> To: "Struts Users Mailing List" <user@(protected)>
> Date: Sunday, July 13, 2008, 4:43 PM
> With Struts1, if I wished to render a JSP page without
> bothering with the
> machinery of an action (yet going through the
> filters/interceptors), I would
> have an action mapping as follows:
>
>      <action path="/home"
> forward="/static/home.jsp" />
>
> With Struts2, in the same situation, I would do:
>
>      <action name="home"
> class="com.opensymphony.xwork2.ActionSupport">
>         <result>/static/home.jsp</result>
>      </action>
>
> This is a case where Struts2 is a lot wordier than Struts1.
> (I have to do
> this about 15 times, for the site's "static"
> pages...)
>
> Is there a shorthand version?

Attachment: user_188801.ezm (zipped)
Brilliant! Thanks, Dave!

2008/7/13 Dave Newton <newton.dave@(protected)>:

> Depending on how your application is laid out you could also put a
> "catch-all" mapping at the end of your regular mappings, like so:
>
> <action name="*">
> <result>/static/{1}.jsp</result>
> </action>
>
> Again, this is if you're intent on using XML configuration.
>

Attachment: user_188805.ezm (zipped)

> 2008/7/13 Dave Newton <newton.dave@(protected)>:
>
>  
>> Again, this is if you're intent on using XML configuration.
>>
>>  

Dave didn't mention that if you're NOT intent on using XML
configuration, then the CodeBehind plugin was created exactly for this
purpose.

http://struts.apache.org/2.x/docs/codebehind-plugin.html


Attachment: user_188807.ezm (zipped)
(Struts 2.1.2)
In the JSP, is it possible through some OGNL expression to get hold of the
URL of the current request? I looked through the XML output obtained
through debugging, but could not find anything.

(I know I can get hold of the action and parameters; so there might a
complicated way out...)

Attachment: user_188808.ezm (zipped)
Pierre Thibaudeau wrote:
> (Struts 2.1.2)
> In the JSP, is it possible through some OGNL expression to get hold of the
> URL of the current request? I looked through the XML output obtained
> through debugging, but could not find anything.
>
> (I know I can get hold of the action and parameters; so there might a
> complicated way out...)
>  

The HttpServletRequest includes the getRequestURI() method. You can
access that easily using EL but OGNL is a little obscure.

The request object is available in the context map in a property called
"com.opensymphony.xwork2.dispatcher.HttpServletRequest".

<s:property
value="%{#context['com.opensymphony.xwork2.dispatcher.HttpServletRequest'].requestURI}"/>




Attachment: user_188809.ezm (zipped)
Hello Jeromy,
I thought of your OGNL solution a few minutes ago, just before reading your
post. I had been so adamant on finding the value explicitly within the
value stack, that I had momentarily forgotten that I had access to the
HttpServletRequest object.

But your statement about EL intrigues me. How would you do that in EL? Is
there some value available to EL in the request context?


2008/7/14 Jeromy Evans <jeromy.evans@(protected)>:

> The HttpServletRequest includes the getRequestURI() method. You can access
> that easily using EL but OGNL is a little obscure.
>
> The request object is available in the context map in a property called
> "com.opensymphony.xwork2.dispatcher.HttpServletRequest".
>
> <s:property
> value="%{#context['com.opensymphony.xwork2.dispatcher.HttpServletRequest'].requestURI}"/>
>

Attachment: user_188812.ezm (zipped)
Pierre Thibaudeau wrote:
>
> But your statement about EL intrigues me. How would you do that in EL? Is
> there some value available to EL in the request context?
>
>  
simply ${pageContext.request.requestURI}

The benefit of EL is that your IDE (hopefully) understands it, which in
my opinion is much better than hardcoding obscure constant strings into
OGNL expressions that fail silently :-)

Attachment: user_188815.ezm (zipped)
>
> The benefit of EL is that your IDE (hopefully) understands it,


I wish my MyEclipse JSP editor was as clever as that... (Should I just
revert to Eclipse with the correct collection of plugins? or maybe switch to
IntelliJ?)
In any case, thanks a million!

Attachment: user_188810.ezm (zipped)
Hi,

     Thanks for your reply, but i am talking about UI screen, not a
table display. in the screen itself for every control i want to apply an
alternate back ground color. for example

<s:textfield name="empid" label="Employee ID :">
<s:textfield name="empname" label="Employee Name : ">

these two should come with two different background colors.

On Thu, Jul 10, 2008 at 3:18 PM, Narayana S <narayanasgs1@(protected):

> Hi,
>
>      as per my requirement, i have to apply two different colors to
> alternate rows.can any one guide me how to extend theme to implement this?
>

Attachment: user_188817.ezm (zipped)
<s:textfield name="empid" label="Employee ID :" cssClass="class1">
<s:textfield name="empname" label="Employee Name : " cssClass="class2">


.class1{
 background-color:red;
}
.class2{
 background-color:blue;
}

Sorry I have not seen your earlier mail, what ever you want to do using
class


Regards,

Jishnu Viswanath

Software Engineer

*(+9180)41190300 - 222(Ext) ll * ( + 91 ) 9731209330ll

Tavant Technologies Inc.,

www.tavant.com

PEOPLE :: PASSION :: EXCELLENCE

-----Original Message-----
From: Narayana S [mailto:narayanasgs1@(protected)]
Sent: Monday, July 14, 2008 11:40 AM
To: Struts Users Mailing List
Subject: Re: Customizing CSS

Hi,

     Thanks for your reply, but i am talking about UI screen, not a
table display. in the screen itself for every control i want to apply an
alternate back ground color. for example

<s:textfield name="empid" label="Employee ID :">
<s:textfield name="empname" label="Employee Name : ">

these two should come with two different background colors.

On Thu, Jul 10, 2008 at 3:18 PM, Narayana S <narayanasgs1@(protected)>
wrote:

> Hi,
>
>      as per my requirement, i have to apply two different colors to
> alternate rows.can any one guide me how to extend theme to implement
this?
>
Any comments or statements made in this email are not necessarily those of Tavant Technologies.
The information transmitted is intended only for the person or entity to which it is addressed and may
contain confidential and/or privileged material. If you have received this in error, please contact the
sender and delete the material from any computer. All e-mails sent from or to Tavant Technologies
may be subject to our monitoring procedures.


Attachment: user_188825.ezm (zipped)
Hi Jishnu,

      Thanks for your reply, it applies background color to the text
field, but i want it to be applied to that entire row(that have label
employee id and text field), not to the text field component alone.



On Mon, Jul 14, 2008 at 12:19 PM, Jishnu Viswanath <
jishnu.viswanath@(protected):

> <s:textfield name="empid" label="Employee ID :" cssClass="class1">
> <s:textfield name="empname" label="Employee Name : " cssClass="class2">
>
>
> .class1{
>     background-color:red;
> }
> .class2{
>     background-color:blue;
> }
>
> Sorry I have not seen your earlier mail, what ever you want to do using
> class
>
>
> Regards,
>
> Jishnu Viswanath
>
> Software Engineer
>
> *(+9180)41190300 - 222(Ext) ll * ( + 91 ) 9731209330ll
>
> Tavant Technologies Inc.,
>
> www.tavant.com
>
> PEOPLE :: PASSION :: EXCELLENCE
>
> -----Original Message-----
> From: Narayana S [mailto:narayanasgs1@(protected)]
> Sent: Monday, July 14, 2008 11:40 AM
> To: Struts Users Mailing List
> Subject: Re: Customizing CSS
>
> Hi,
>
>      Thanks for your reply, but i am talking about UI screen, not a
> table display. in the screen itself for every control i want to apply an
> alternate back ground color. for example
>
> <s:textfield name="empid" label="Employee ID :">
> <s:textfield name="empname" label="Employee Name : ">
>
> these two should come with two different background colors.
>
> On Thu, Jul 10, 2008 at 3:18 PM, Narayana S <narayanasgs1@(protected)>
> wrote:
>
> > Hi,
> >
> >      as per my requirement, i have to apply two different colors to
> > alternate rows.can any one guide me how to extend theme to implement
> this?
> >
> Any comments or statements made in this email are not necessarily those of
> Tavant Technologies.
> The information transmitted is intended only for the person or entity to
> which it is addressed and may
> contain confidential and/or privileged material. If you have received this
> in error, please contact the
> sender and delete the material from any computer. All e-mails sent from or
> to Tavant Technologies
> may be subject to our monitoring procedures.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

Attachment: user_188827.ezm (zipped)
I don't have much idea, but you can give it a try on <s:label
value="Employee ID" cssClass="class2"/>

Regards,

Jishnu Viswanath

Software Engineer

*(+9180)41190300 - 222(Ext) ll * ( + 91 ) 9731209330ll

Tavant Technologies Inc.,

www.tavant.com

PEOPLE :: PASSION :: EXCELLENCE


-----Original Message-----
From: Narayana S [mailto:narayanasgs1@(protected)]
Sent: Monday, July 14, 2008 1:47 PM
To: Struts Users Mailing List
Subject: Re: Customizing CSS

Hi Jishnu,

      Thanks for your reply, it applies background color to the
text
field, but i want it to be applied to that entire row(that have label
employee id and text field), not to the text field component alone.



On Mon, Jul 14, 2008 at 12:19 PM, Jishnu Viswanath <
jishnu.viswanath@(protected):

> <s:textfield name="empid" label="Employee ID :" cssClass="class1">
> <s:textfield name="empname" label="Employee Name : "
cssClass="class2">
>
>
> .class1{
>     background-color:red;
> }
> .class2{
>     background-color:blue;
> }
>
> Sorry I have not seen your earlier mail, what ever you want to do
using
> class
>
>
> Regards,
>
> Jishnu Viswanath
>
> Software Engineer
>
> *(+9180)41190300 - 222(Ext) ll * ( + 91 ) 9731209330ll
>
> Tavant Technologies Inc.,
>
> www.tavant.com
>
> PEOPLE :: PASSION :: EXCELLENCE
>
> -----Original Message-----
> From: Narayana S [mailto:narayanasgs1@(protected)]
> Sent: Monday, July 14, 2008 11:40 AM
> To: Struts Users Mailing List
> Subject: Re: Customizing CSS
>
> Hi,
>
>      Thanks for your reply, but i am talking about UI screen, not a
> table display. in the screen itself for every control i want to apply
an
> alternate back ground color. for example
>
> <s:textfield name="empid" label="Employee ID :">
> <s:textfield name="empname" label="Employee Name : ">
>
> these two should come with two different background colors.
>
> On Thu, Jul 10, 2008 at 3:18 PM, Narayana S <narayanasgs1@(protected)>
> wrote:
>
> > Hi,
> >
> >      as per my requirement, i have to apply two different colors
to
> > alternate rows.can any one guide me how to extend theme to implement
> this?
> >
> Any comments or statements made in this email are not necessarily
those of
> Tavant Technologies.
> The information transmitted is intended only for the person or entity
to
> which it is addressed and may
> contain confidential and/or privileged material. If you have received
this
> in error, please contact the
> sender and delete the material from any computer. All e-mails sent
from or
> to Tavant Technologies
> may be subject to our monitoring procedures.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
Any comments or statements made in this email are not necessarily those of Tavant Technologies.
The information transmitted is intended only for the person or entity to which it is addressed and may
contain confidential and/or privileged material. If you have received this in error, please contact the
sender and delete the material from any computer. All e-mails sent from or to Tavant Technologies
may be subject to our monitoring procedures.


Attachment: user_188811.ezm (zipped)

hi,

i didnt get you. I have a page for which i need to do some preprocessing to
display it. After the page is done by user it has to be processed. Can you
please elaborate on the soln given?

ravi


Gabriel Belingueres-2 wrote:
>
> Sorry it seems I entered the conversation later and didn't saw that email.
>
> The problem you want to solve is very common (skipping form validation
> the first time you call an action) and, as Dave wrote, it is commonly
> solved by invoking the action with the input() method [1]. This method
> will do nothing and will return INPUT as the result, thus forwarding
> the response to the page with the form.
>
> [1]
> http://struts.apache.org/2.1.2/struts2-core/apidocs/com/opensymphony/xwork2/ActionSupport.html#input()
>
> 2008/7/12 Andreas Mähler <andreas.maehler@(protected)>:
>> Hello again,
>>
>> Gabriel Belingueres schrieb:
>>>
>>> Without knowing what are you actually trying to accomplish with this
>>> interceptor, I would warn that when an interceptor messes up with the
>>> parameters, you need to carefully think where in the interceptor chain
>>> this interceptor will execute.
>>
>> I explain what I am trying to do in my first post[1].
>>
>> What do you mean by messing up with the parameters? The Interceptor only
>> checks for the presence of at least one of the specified parameters. It
>> does
>> not change anything. Are there any interceptors that actually change the
>> parameter map? As I said, I am a S2 newbie and haven't heard of many
>> things,
>> but I would consider it as bad style.
>>
>> Greetings,
>> ~Andreas
>>
>>
>> [1] http://article.gmane.org/gmane.comp.jakarta.struts.user/158395
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_188813.ezm (zipped)
Hi,

     I have extended Simple theme (by modifying XHTML theme),
implemented the column span for every control as given below.

<s:textfield label="Trucker" name="truker" size="70">
  <s:param name="labelcolspan" value="%{2}" />
  <s:param name="inputcolspan" value="%{6}" />
</s:textfield>

it is working fine.

Now to pass these parameters directly within the textfield tag, i have
extended org.apache.struts2.views.jsp.ui.TextFieldTag and created my own tag
with new attributes labelcolspan,inputcolspan. the taglib file also modified
accordingly, but when i am creating a textfield with the extended class, it
is not passing these two new parameter info to Free marker template files.
after extending as shown below i am using the tag,

<ss:textfield labelcolspan="row21" inputcolspan="row31" name="myname1"
label="Enter First Name" />


what else i am missing here? can any one suggest me....

Thanks in advance
~narayana.

Attachment: user_188814.ezm (zipped)

yes it doesnt. Atleast in version 2.0.9. i heard its fixed in 2.1 version.
you can write a reset interceptor also for this. i.e. always (before param
interceptor) reset the checkbox field. If there is some checkbox getting
submitted then you will get them, else the field would be reset by the
interceptor.

hth
ravi



Owen Berry wrote:
>
> I would have thought <s:checkbox.../> would handle all of that for
> you, but I guess it may not be working, or doesn't aim to.
>
> 2008/7/10 Paweł Wielgus <poulwiel@(protected)>:
>> Hi all,
>> just yesterday i had the very same problem in rails with date field,
>> so i searched for disabled definition and found this:
>> http://www.w3.org/TR/html401/interact/forms.html#successful-controls
>> and
>> http://www.w3.org/TR/html401/interact/forms.html#h-17.12
>> It looks like disabled flag will simply prevent the field from submiting.
>>
>> So an extra hidden field read-only should do the job.
>>
>> Best greetings,
>> Paweł Wielgus.
>>
>> On 10/07/2008, Dave Newton <newton.dave@(protected):
>>> --- On Wed, 7/9/08, Owen Berry <owen.berry@(protected):
>>> > You need to have a hidden field value that will take the
>>> > place of the disabled checkbox as some browsers do not
>>> > send disabled field values.
>>>
>>>
>>> The <s:checkbox.../> tag already includes the hidden field; I don't know
>>> what it does for disabled checkboxes, though. The checkbox interceptor
>>> *should* work in concert with the tag to handle disabled checkboxes as
>>> well, or at least I thought it did.
>>>
>>>
>>> Dave
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>> For additional commands, e-mail: user-help@(protected)
>>>
>>>
>>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_188816.ezm (zipped)
Hi all!

Been looking all over the net but my validation simply isn't working :(



I have a JSP page with a dropdown box in a form.

I just want to make sure the value in the dropdown box is not empty.

It currently looks like this:



<s:form action=3D"myaction" method=3D"post" validate=3D"true">

    <s:actionerror />

    <s:fielderror />



    <s:select name=3D"fieldName"

          id=3D"fieldName"

          theme=3D"simple"

          size=3D"1"

          list=3D"fieldList"

          headerKey=3D""

          headerValue=3D"- - Please Select - -"/>

    <s:submit name=3D"Submit"/>

</s:form>



My setup is that I have an Action class, which uses a Form to set and get f= ield values from the JSP page.

In Struts1 I was using the validate(...) method in the Form class.

It seems none of the Struts2 validation examples on the net are working for= me.

Or I'm not doing it right.



Anyone any ideas how I can do this simply?



Cheers!

nic


________________________________
The contents of this email are confidential and may be subject to legal or professional privilege and copyright. No representation is made that this email is free of viruses or other defects. If you have received this communication in error, you may not copy or distribute any part of it or otherwise disclose its contents to anyone. Please advise the sender of your incorrect receipt of this correspondence.

Attachment: user_188818.ezm (zipped)
Nicole Luneburg wrote:
>
>
>
> <s:form action=3D"myaction" method=3D"post" validate=3D"true">
>  
The validate attribute here is used to enable client-side validation
only. That will only work if you include the <s:head> attribute in the
page.


>
>
> My setup is that I have an Action class, which uses a Form to set and get f= ield values from the JSP page.
>
> In Struts1 I was using the validate(...) method in the Form class.
>
> It seems none of the Struts2 validation examples on the net are working for= me.
>
>  

You haven't mentioned whether you're using XML validation or
annotation-based validation. If by not working you mean "does nothing",
then your XML file is probably incorrectly named or your missing an
annotation. (You need to enable this separately from client-side
validation)

Whatever the case, the main difference between Struts1 and Struts2 here
is that Struts2 performs validation on the Object, not on the form
parameters.
That means, to check that "fieldName" is non-blank, it will call
getFieldName() after setFieldName() was called by the ParametersInterceptor.

A common problem is to forget the getter, but in that case Struts will
keep returning INPUT (validation failed) instead of invoking your action.

Hope that helps,
Jeromy Evans





Attachment: user_188820.ezm (zipped)
If you want validation like in struts1 you can implement the interface
com.opensymphony.xwork2.Validateable in your Action class. The method
validate() is the same as in your struts1 FormBean.

But maybe that's a bit old fashioned :)

Regards
--
Markus Stauffer

On Mon, Jul 14, 2008 at 8:54 AM, Jeromy Evans
<jeromy.evans@(protected):
> Nicole Luneburg wrote:
>>
>>
>>
>> <s:form action=3D"myaction" method=3D"post" validate=3D"true">
>>
>
> The validate attribute here is used to enable client-side validation only.
> That will only work if you include the <s:head> attribute in the page.
>
>
>>
>>
>> My setup is that I have an Action class, which uses a Form to set and get
>> f= ield values from the JSP page.
>>
>> In Struts1 I was using the validate(...) method in the Form class.
>>
>> It seems none of the Struts2 validation examples on the net are working
>> for= me.
>>
>>
>
> You haven't mentioned whether you're using XML validation or
> annotation-based validation. If by not working you mean "does nothing",
> then your XML file is probably incorrectly named or your missing an
> annotation. (You need to enable this separately from client-side
> validation)
>
> Whatever the case, the main difference between Struts1 and Struts2 here is
> that Struts2 performs validation on the Object, not on the form parameters.
> That means, to check that "fieldName" is non-blank, it will call
> getFieldName() after setFieldName() was called by the ParametersInterceptor.
>
> A common problem is to forget the getter, but in that case Struts will keep
> returning INPUT (validation failed) instead of invoking your action.
>
> Hope that helps,
> Jeromy Evans
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

Attachment: user_188821.ezm (zipped)
ps. My post added some "3D" text that isn't supposed to be there ...

Thanks Jeromy.

Yes I do have a <s:head> attribute, maybe not *exactly* but I have:
<s:head theme="ajax" />

Apologies for the confusion.
What I meant in my pevious post was that I had tried a few ways to do this validation task.
In my initial post I had described one of these attempts which I think should have worked.

What I am getting regardless of what sort of validation I try to implement is this error:

java.lang.StringIndexOutOfBoundsException: String index out of range: -7

You mentioned the getters and setters for the fieldnames ... this only works though if the fields are stored in the action right?
coz the fields I have aren't stored in the action, they are stored in a Form class.

Ie my action looks something like:

public String execute() {
    MyForm myForm = (MyForm)super.form;
    String myField = myForm.getFieldName();
}

Markus: Thanks for your reply too, I am trying it right now. Just want this to work grrr


-----Original Message-----
From: Jeromy Evans [mailto:jeromy.evans@(protected)]
Sent: Monday, 14 July 2008 4:25 PM
To: Struts Users Mailing List
Subject: Re: struts2 validation

Nicole Luneburg wrote:
>
>
>
> <s:form action=3D"myaction" method=3D"post" validate=3D"true">
>
The validate attribute here is used to enable client-side validation
only. That will only work if you include the <s:head> attribute in the
page.


>
>
> My setup is that I have an Action class, which uses a Form to set and get f= ield values from the JSP page.
>
> In Struts1 I was using the validate(...) method in the Form class.
>
> It seems none of the Struts2 validation examples on the net are working for= me.
>
>

You haven't mentioned whether you're using XML validation or
annotation-based validation. If by not working you mean "does nothing",
then your XML file is probably incorrectly named or your missing an
annotation. (You need to enable this separately from client-side
validation)

Whatever the case, the main difference between Struts1 and Struts2 here
is that Struts2 performs validation on the Object, not on the form
parameters.
That means, to check that "fieldName" is non-blank, it will call
getFieldName() after setFieldName() was called by the ParametersInterceptor.

A common problem is to forget the getter, but in that case Struts will
keep returning INPUT (validation failed) instead of invoking your action.

Hope that helps,
Jeromy Evans





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


The contents of this email are confidential and may be subject to legal or professional privilege and copyright. No representation is made that this email is free of viruses or other defects. If you have received this communication in error, you may not copy or distribute any part of it or otherwise disclose its contents to anyone. Please advise the sender of your incorrect receipt of this correspondence.

Attachment: user_188822.ezm (zipped)
Struts2 does not have FormBeans anymore. All the form fields are
instance variables directly in your Action class. Simply include a
variable fieldName of type String with getters and setters in your
Action class. The setFieldName() method will be called when you submit
the form. In the execute() and validate() methods you can use the
fieldName variable directly.

What you can also do is put a instance variable of a bean in your
Action class. You can then acces the getters and setters of this bean
in the jsp:

<s:form action="myaction">
    <s:select name="myBeanVariableName.fieldName"
             theme="simple"
             list="fieldList"
             headerKey=""
             headerValue="- - Please Select - -"/>
</s:form>

If you submit this form struts will call
myaction.getMyBeanVariableName().setFieldName(selectedValue).


Regards
--
Markus Stauffer


On Mon, Jul 14, 2008 at 9:16 AM, Nicole Luneburg
<Nicole.Luneburg@(protected):
> ps. My post added some "3D" text that isn't supposed to be there ...
>
> Thanks Jeromy.
>
> Yes I do have a <s:head> attribute, maybe not *exactly* but I have:
> <s:head theme="ajax" />
>
> Apologies for the confusion.
> What I meant in my pevious post was that I had tried a few ways to do this validation task.
> In my initial post I had described one of these attempts which I think should have worked.
>
> What I am getting regardless of what sort of validation I try to implement is this error:
>
> java.lang.StringIndexOutOfBoundsException: String index out of range: -7
>
> You mentioned the getters and setters for the fieldnames ... this only works though if the fields are stored in the action right?
> coz the fields I have aren't stored in the action, they are stored in a Form class.
>
> Ie my action looks something like:
>
> public String execute() {
>     MyForm myForm = (MyForm)super.form;
>     String myField = myForm.getFieldName();
> }
>
> Markus: Thanks for your reply too, I am trying it right now. Just want this to work grrr
>
>
> -----Original Message-----
> From: Jeromy Evans [mailto:jeromy.evans@(protected)]
> Sent: Monday, 14 July 2008 4:25 PM
> To: Struts Users Mailing List
> Subject: Re: struts2 validation
>
> Nicole Luneburg wrote:
>>
>>
>>
>> <s:form action=3D"myaction" method=3D"post" validate=3D"true">
>>
> The validate attribute here is used to enable client-side validation
> only. That will only work if you include the <s:head> attribute in the
> page.
>
>
>>
>>
>> My setup is that I have an Action class, which uses a Form to set and get f= ield values from the JSP page.
>>
>> In Struts1 I was using the validate(...) method in the Form class.
>>
>> It seems none of the Struts2 validation examples on the net are working for= me.
>>
>>
>
> You haven't mentioned whether you're using XML validation or
> annotation-based validation. If by not working you mean "does nothing",
> then your XML file is probably incorrectly named or your missing an
> annotation. (You need to enable this separately from client-side
> validation)
>
> Whatever the case, the main difference between Struts1 and Struts2 here
> is that Struts2 performs validation on the Object, not on the form
> parameters.
> That means, to check that "fieldName" is non-blank, it will call
> getFieldName() after setFieldName() was called by the ParametersInterceptor.
>
> A common problem is to forget the getter, but in that case Struts will
> keep returning INPUT (validation failed) instead of invoking your action.
>
> Hope that helps,
> Jeromy Evans
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
> The contents of this email are confidential and may be subject to legal or professional privilege and copyright. No representation is made that this email is free of viruses or other defects. If you have received this communication in error, you may not copy or distribute any part of it or otherwise disclose its contents to anyone. Please advise the sender of your incorrect receipt of this correspondence.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

Attachment: user_188819.ezm (zipped)
Hi!

I'm using struts version 2.0.11.
I am using struts menu, which works provided it is not on top of a table ...
Please see screenshot of issue here:
http://mytmpdir.googlepages.com/menu.jpg

No idea how I can fix this!
Does anyone?

Thanks guys

Attachment: user_188823.ezm (zipped)
Hi!

Will REST plugin replace JSON plugin in Struts 2.1?
To my mind JSON plugin was very REST-like, and I was
really hoping that it would evolve into something that
REST plugin claims to be.

Also, do REST and JSON plugins have anything in common?
After I read REST plugin author's Struts 2 in Action
book it seemed that he wasn't aware of JSON plugin at
all - he devoted several pages to implementation of a
custom JSON handlers instead of just dropping JSON
plugin into Struts 2 stack......

Oleg


Attachment: user_188824.ezm (zipped)
Oleg Mikheev wrote:
> Hi!
>
> Will REST plugin replace JSON plugin in Struts 2.1?
> To my mind JSON plugin was very REST-like, and I was
> really hoping that it would evolve into something that
> REST plugin claims to be.
>
> Also, do REST and JSON plugins have anything in common?

They're not related except both can serialize an action/model into JSON.

In the past I created a ContentTypeHandler for the REST Plugin that used
the JSON plugin's serializer. The result was exactly the same.

The REST plugin uses json-lib for its default JSON ContentTypeHandler.
(http://json-lib.sourceforge.net/)
The advantage of JSON-lib is that it's bidirectional (essential for the
plugin) and is used in many frameworks.
The advantage of the JSON-plugin is that it includes some simple options
to customize the output specifically for S2 (such as changing the root
object).

I've contributed to both the JSON plugin and REST plugin and use the
JSON plugin when I'm writing plain actions that return JSON responses
and json-lib when using the REST plugin. The options the JSON-plugin
provides are generally not relevant when using the REST plugin so it's
not valuable to run both.

The JSON plugin should probably be updated to allow the serializer to be
customized so you can use the json-lib serializer or the native serializer.

> After I read REST plugin author's Struts 2 in Action
> book it seemed that he wasn't aware of JSON plugin at
> all - he devoted several pages to implementation of a
> custom JSON handlers instead of just dropping JSON
> plugin into Struts 2 stack......
>

I presume that's just because the JSON plugin isn't part of the Struts 2
distribution per se.



Attachment: user_188826.ezm (zipped)

hi

Thanks

i have see documents and search for applying single sign on feature and
jdbc realm for security but i can not get properly ,could you provide me
some links which can use to understand from scratch all this things,
thanks

--
Sent from the Struts - User mailing list archive at Nabble.com.

©2008 gg3721.com - Jax Systems, LLC, U.S.A.