Re: trouble retrieving a request parameter with struts2 tags

2009-06-07 Thread Dimitrios Christodoulakis
That is interesting. I tried using the escapeTick=true attribute
with the s:url, but got an exception:

org.apache.jasper.JasperException: /pages/list.jsp(26,6) Attribute
escapeTick invalid for tag url according to TLD

A further look at the struts 2 tag reference:
http://struts.apache.org/2.1.6/docs/url.html
Doesn't indicate that the url tag has such an attribute -- I am using
struts 2 version 2.1.6, was that attribute used in other versions?

Since you mentioned it, I tried an example, without the escapeTick
attribute and the URL now forms like this:
http://localhost/MyApp/edit.action?id=69firstName=colinlastName=o%27hara

Although the tick (or apostrophe) is not escaped, when I retrieve the
lastName parameter to have the field pre-populated, the name is
rendered correctly.

But, you made a good point, are there other ways to escape special
characters with attributes, or further manual coding are needed?

On Sat, Jun 6, 2009 at 10:26 PM, Martin Gaintymgai...@hotmail.com wrote:

 yes that works for john doe
 but those of us with irish names like patrick o'donnell would need the tick 
 mark escaped
  s:url action=edit var=editURL escapeAmp = false escapeTick=true
 ?
 Martin Gainty
 __
 Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

 Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
 sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
 oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich 
 dem Austausch von Informationen und entfaltet keine rechtliche 
 Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen 
 wir keine Haftung fuer den Inhalt uebernehmen.
 Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
 destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
 l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci 
 est interdite. Ce message sert à l'information seulement et n'aura pas 
 n'importe quel effet légalement obligatoire. Étant donné que les email 
 peuvent facilement être sujets à la manipulation, nous ne pouvons accepter 
 aucune responsabilité pour le contenu fourni.




 Date: Sat, 6 Jun 2009 13:13:08 -0500
 Subject: Re: trouble retrieving a request parameter with struts2 tags
 From: dimi@gmail.com
 To: user@struts.apache.org

 With a little bit more searching I found the escapeAmp attribute of
 the s:url tag. That did the trick:

 s:url action=edit var=editURL escapeAmp = false

 Thanks!

 On Sat, Jun 6, 2009 at 10:41 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
  Thank you for the information. That ofnl expression actually worked.
  The textfield is populated with the value taken from the URL
  parameter.
 
  But something strange happens when I try to put more parameters on the 
  request:
 
  s:url action=edit var=editURL
         s:param name=id value=%{id} /
         s:param name=firstName value=%{firstName} /
         s:param name=lastName value=%{lastName} /
  /s:url
 
  So the link forms like this:
 
  http://localhost/MyApp/edit.action?id=38firstName=johnlastName=doe
 
  Next, on the update page, I try to retrieve not only the id, but the
  first name and last name too from the URL (in order to pre-fill the
  textfields):
 
  s:form action=save
           s:textfield name=person.firstName
  value=%{#parameters.firstName} label=First Name/
           s:textfield name=person.lastName
  value=%{#parameters.lastName} label=Last Name/
           s:hidden name=person.id value=%{#parameters.id}
  label=Primary Key /
           s:submit/
  /s:form
 
  Although ognl correctly picks up the first parameter (id), takes its
  value and populates the hidden field, I get 2 ognl warnings: one for
  the first name and one for the last name:
 
  WARN OgnlValueStack:49 - Error setting value
  ognl.ExpressionSyntaxException: Malformed OGNL expression:
  amp;firstName [ognl.TokenMgrError: Lexical error at line 1, column 4.
  Encountered: ; (59), after : ]
 
  WARN OgnlValueStack:49 - Error setting value
  ognl.ExpressionSyntaxException: Malformed OGNL expression:
  amp;lastName [ognl.TokenMgrError: Lexical error at line 1, column 4.
  Encountered: ; (59), after : ]
 
  A look at how the URL forms confirms this: Instead of adding the
  parameters in URL using just a , parameters are separated by this:
  
 
  --Is that some sort of bug when evaluating multiple struts2 param tags
  with ognl, or do I have something wrong in the jsp code?
  The actual action ode works ok, I believe the issue is within that jsp 
  only.
 
  Again, I appreciate any further advice on this.
  Regards to everyone.
 
 
 
  On Fri, Jun 5, 2009 at 9:32 PM, Dave Newtonnewton.d...@yahoo.com wrote:
  Dimitrios Christodoulakis wrote:
 
  s:hidden name=person.id value=#attr.id label=Primary Key /
 
  I told you #attr.id on javaranch; I meant #parameters. This information is
  readily

Re: trouble retrieving a request parameter with struts2 tags

2009-06-07 Thread Dave Newton

Dimitrios Christodoulakis wrote:

A further look at the struts 2 tag reference:
http://struts.apache.org/2.1.6/docs/url.html
Doesn't indicate that the url tag has such an attribute -- I am using
struts 2 version 2.1.6, was that attribute used in other versions?


No. I assumed an attempt at humor, but was just confusing instead.


But, you made a good point, are there other ways to escape special
characters with attributes, or further manual coding are needed?


AFAIK s:url and s:property will encode things in an HTML-reasonable 
way by default. s:property adds the escapeJavaScript property for 
use in JS expressions.


Dave

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: trouble retrieving a request parameter with struts2 tags

2009-06-06 Thread Dimitrios Christodoulakis
Thank you for the information. That ofnl expression actually worked.
The textfield is populated with the value taken from the URL
parameter.

But something strange happens when I try to put more parameters on the request:

s:url action=edit var=editURL
s:param name=id value=%{id} /
s:param name=firstName value=%{firstName} /
s:param name=lastName value=%{lastName} /
/s:url

So the link forms like this:

http://localhost/MyApp/edit.action?id=38amp;firstName=johnamp;lastName=doe

Next, on the update page, I try to retrieve not only the id, but the
first name and last name too from the URL (in order to pre-fill the
textfields):

s:form action=save  
  s:textfield name=person.firstName
value=%{#parameters.firstName} label=First Name/
  s:textfield name=person.lastName
value=%{#parameters.lastName} label=Last Name/
  s:hidden name=person.id value=%{#parameters.id}
label=Primary Key /
  s:submit/
/s:form   

Although ognl correctly picks up the first parameter (id), takes its
value and populates the hidden field, I get 2 ognl warnings: one for
the first name and one for the last name:

WARN OgnlValueStack:49 - Error setting value
ognl.ExpressionSyntaxException: Malformed OGNL expression:
amp;firstName [ognl.TokenMgrError: Lexical error at line 1, column 4.
Encountered: ; (59), after : ]

WARN OgnlValueStack:49 - Error setting value
ognl.ExpressionSyntaxException: Malformed OGNL expression:
amp;lastName [ognl.TokenMgrError: Lexical error at line 1, column 4.
Encountered: ; (59), after : ]

A look at how the URL forms confirms this: Instead of adding the
parameters in URL using just a , parameters are separated by this:
amp;

--Is that some sort of bug when evaluating multiple struts2 param tags
with ognl, or do I have something wrong in the jsp code?
The actual action ode works ok, I believe the issue is within that jsp only.

Again, I appreciate any further advice on this.
Regards to everyone.



On Fri, Jun 5, 2009 at 9:32 PM, Dave Newtonnewton.d...@yahoo.com wrote:
 Dimitrios Christodoulakis wrote:

 s:hidden name=person.id value=#attr.id label=Primary Key /

 I told you #attr.id on javaranch; I meant #parameters. This information is
 readily available via the S2 docs. [1, 2]

 IIRC the value attribute expects a literal; I'd wrap it in the OGNL
 escape, %{#parameters.id}, to make sure it's evaluated. Correct rendering
 is, of course, trivially verifiable by viewing the rendered source.

 The fact remains that if person.id isn't being filled correctly by your Java
 code something is still wrong with it.

 I have also tried unsuccessfully to retrieve the parameter value
 from the action code, but always get null.

 If I'm understanding what you're saying there then something is doubly wrong
 with either your config or your assumptions: there are several ways to
 retrieve URL parameters, and AFAIK they all work.

 Note that the result named SUCCESS will never be used if you're using the
 ActionSupport convenience result constants.

 Dave

 [1] OGNL
 http://struts.apache.org/2.x/docs/ognl.html

 [2] OGNL Basics
 http://struts.apache.org/2.x/docs/ognl-basics.html

 -
 To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
 For additional commands, e-mail: user-h...@struts.apache.org



-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: trouble retrieving a request parameter with struts2 tags

2009-06-06 Thread Dimitrios Christodoulakis
With a little bit more searching I found the escapeAmp attribute of
the s:url tag. That did the trick:

s:url action=edit var=editURL escapeAmp = false

Thanks!

On Sat, Jun 6, 2009 at 10:41 AM, Dimitrios
Christodoulakisdimi@gmail.com wrote:
 Thank you for the information. That ofnl expression actually worked.
 The textfield is populated with the value taken from the URL
 parameter.

 But something strange happens when I try to put more parameters on the 
 request:

 s:url action=edit var=editURL
        s:param name=id value=%{id} /
        s:param name=firstName value=%{firstName} /
        s:param name=lastName value=%{lastName} /
 /s:url

 So the link forms like this:

 http://localhost/MyApp/edit.action?id=38amp;firstName=johnamp;lastName=doe

 Next, on the update page, I try to retrieve not only the id, but the
 first name and last name too from the URL (in order to pre-fill the
 textfields):

 s:form action=save
          s:textfield name=person.firstName
 value=%{#parameters.firstName} label=First Name/
          s:textfield name=person.lastName
 value=%{#parameters.lastName} label=Last Name/
          s:hidden name=person.id value=%{#parameters.id}
 label=Primary Key /
          s:submit/
 /s:form

 Although ognl correctly picks up the first parameter (id), takes its
 value and populates the hidden field, I get 2 ognl warnings: one for
 the first name and one for the last name:

 WARN OgnlValueStack:49 - Error setting value
 ognl.ExpressionSyntaxException: Malformed OGNL expression:
 amp;firstName [ognl.TokenMgrError: Lexical error at line 1, column 4.
 Encountered: ; (59), after : ]

 WARN OgnlValueStack:49 - Error setting value
 ognl.ExpressionSyntaxException: Malformed OGNL expression:
 amp;lastName [ognl.TokenMgrError: Lexical error at line 1, column 4.
 Encountered: ; (59), after : ]

 A look at how the URL forms confirms this: Instead of adding the
 parameters in URL using just a , parameters are separated by this:
 amp;

 --Is that some sort of bug when evaluating multiple struts2 param tags
 with ognl, or do I have something wrong in the jsp code?
 The actual action ode works ok, I believe the issue is within that jsp only.

 Again, I appreciate any further advice on this.
 Regards to everyone.



 On Fri, Jun 5, 2009 at 9:32 PM, Dave Newtonnewton.d...@yahoo.com wrote:
 Dimitrios Christodoulakis wrote:

 s:hidden name=person.id value=#attr.id label=Primary Key /

 I told you #attr.id on javaranch; I meant #parameters. This information is
 readily available via the S2 docs. [1, 2]

 IIRC the value attribute expects a literal; I'd wrap it in the OGNL
 escape, %{#parameters.id}, to make sure it's evaluated. Correct rendering
 is, of course, trivially verifiable by viewing the rendered source.

 The fact remains that if person.id isn't being filled correctly by your Java
 code something is still wrong with it.

 I have also tried unsuccessfully to retrieve the parameter value
 from the action code, but always get null.

 If I'm understanding what you're saying there then something is doubly wrong
 with either your config or your assumptions: there are several ways to
 retrieve URL parameters, and AFAIK they all work.

 Note that the result named SUCCESS will never be used if you're using the
 ActionSupport convenience result constants.

 Dave

 [1] OGNL
 http://struts.apache.org/2.x/docs/ognl.html

 [2] OGNL Basics
 http://struts.apache.org/2.x/docs/ognl-basics.html

 -
 To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
 For additional commands, e-mail: user-h...@struts.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



RE: trouble retrieving a request parameter with struts2 tags

2009-06-06 Thread Martin Gainty

yes that works for john doe
but those of us with irish names like patrick o'donnell would need the tick 
mark escaped
 s:url action=edit var=editURL escapeAmp = false escapeTick=true
?
Martin Gainty 
__ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.




 Date: Sat, 6 Jun 2009 13:13:08 -0500
 Subject: Re: trouble retrieving a request parameter with struts2 tags
 From: dimi@gmail.com
 To: user@struts.apache.org
 
 With a little bit more searching I found the escapeAmp attribute of
 the s:url tag. That did the trick:
 
 s:url action=edit var=editURL escapeAmp = false
 
 Thanks!
 
 On Sat, Jun 6, 2009 at 10:41 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
  Thank you for the information. That ofnl expression actually worked.
  The textfield is populated with the value taken from the URL
  parameter.
 
  But something strange happens when I try to put more parameters on the 
  request:
 
  s:url action=edit var=editURL
 s:param name=id value=%{id} /
 s:param name=firstName value=%{firstName} /
 s:param name=lastName value=%{lastName} /
  /s:url
 
  So the link forms like this:
 
  http://localhost/MyApp/edit.action?id=38amp;firstName=johnamp;lastName=doe
 
  Next, on the update page, I try to retrieve not only the id, but the
  first name and last name too from the URL (in order to pre-fill the
  textfields):
 
  s:form action=save
   s:textfield name=person.firstName
  value=%{#parameters.firstName} label=First Name/
   s:textfield name=person.lastName
  value=%{#parameters.lastName} label=Last Name/
   s:hidden name=person.id value=%{#parameters.id}
  label=Primary Key /
   s:submit/
  /s:form
 
  Although ognl correctly picks up the first parameter (id), takes its
  value and populates the hidden field, I get 2 ognl warnings: one for
  the first name and one for the last name:
 
  WARN OgnlValueStack:49 - Error setting value
  ognl.ExpressionSyntaxException: Malformed OGNL expression:
  amp;firstName [ognl.TokenMgrError: Lexical error at line 1, column 4.
  Encountered: ; (59), after : ]
 
  WARN OgnlValueStack:49 - Error setting value
  ognl.ExpressionSyntaxException: Malformed OGNL expression:
  amp;lastName [ognl.TokenMgrError: Lexical error at line 1, column 4.
  Encountered: ; (59), after : ]
 
  A look at how the URL forms confirms this: Instead of adding the
  parameters in URL using just a , parameters are separated by this:
  amp;
 
  --Is that some sort of bug when evaluating multiple struts2 param tags
  with ognl, or do I have something wrong in the jsp code?
  The actual action ode works ok, I believe the issue is within that jsp only.
 
  Again, I appreciate any further advice on this.
  Regards to everyone.
 
 
 
  On Fri, Jun 5, 2009 at 9:32 PM, Dave Newtonnewton.d...@yahoo.com wrote:
  Dimitrios Christodoulakis wrote:
 
  s:hidden name=person.id value=#attr.id label=Primary Key /
 
  I told you #attr.id on javaranch; I meant #parameters. This information is
  readily available via the S2 docs. [1, 2]
 
  IIRC the value attribute expects a literal; I'd wrap it in the OGNL
  escape, %{#parameters.id}, to make sure it's evaluated. Correct rendering
  is, of course, trivially verifiable by viewing the rendered source.
 
  The fact remains that if person.id isn't being filled correctly by your 
  Java
  code something is still wrong with it.
 
  I have also tried unsuccessfully to retrieve the parameter value
  from the action code, but always get null.
 
  If I'm understanding what you're saying there then something is doubly 
  wrong
  with either your config or your assumptions: there are several ways to
  retrieve URL parameters, and AFAIK they all work.
 
  Note that the result named SUCCESS will never be used if you're using the
  ActionSupport convenience result constants.
 
  Dave
 
  [1] OGNL
  http://struts.apache.org/2.x/docs/ognl.html
 
  [2] OGNL Basics
  http://struts.apache.org/2.x/docs/ognl-basics.html

trouble retrieving a request parameter with struts2 tags

2009-06-05 Thread Dimitrios Christodoulakis
Hello,

I am building a struts2-hibernate-mysql application. A user after
navigating through some pages reaches a pages where all the records on
the database are listed and can perform crud operations.

The jsp which iterates and displays the records is:

%@ taglib prefix=s uri=/struts-tags%

pPersons found on database/p
a href=s:url action='adduser'/Add new User/a
s:if test=persons.size  0  
table
s:iterator value=persons
tr id=row_s:property value=id/

td
s:property value=id /
/td
td
s:property value=firstName /
/td
td
s:property value=lastName /
/td
td
s:url action=remove 
var=remURL
s:param name=id 
value=id /
/s:url
a href=s:property value 
=remURL/Remove/a  
/td
td
s:url action=edit 
var=editURL
s:param name=id 
value=id /
/s:url
a href=s:property value 
=editURL/Edit/a
/td
td
a style=color: #FF 
href=AccountsView account details/a
/td
/tr
/s:iterator
/table
/s:if
a href=s:url action='admin'/Back to Administrator's homepage/a

---As you can see within the above jsp an edit link is generated for
every record and the record id is passed as a parameter to the URL,
with: s:param name=id value=id /

When the user follows the edit link, the URL forms like this:

http://localhost/MyApp/edit.action?id=38

The record identifier is passed as a parameter in the URL: ?id=38

The link brings the user to a new form to perform a simple edit of the
record; first name and last name:

The jsp with the edit form is the following:

%@ page contentType=text/html; charset=UTF-8 %
%@ taglib prefix=s uri=/struts-tags %
html

head
titleUpdate User/title
s:head/
/head

body
h4Edit information for selected user/h4
s:form action=save  
  s:textfield name=person.firstName
value=%{person.firstName} label=First Name/
  s:textfield name=person.lastName label=Last Name/
  s:hidden name=person.id value=#attr.id label=Primary Key /
  s:submit/
/s:form   

/body

/html

The aim is to have the hidden field pre-filled with the value taken
from the URL parameter as soon as the user clicks on the edit link
and reaches the new form to update a record. Unfortunately so far I
have not been able to retrieve that parameter and use its value to
fill that texfield. The id value is always null.

The consequence is that the code performs a new insert instead of an
update, it sees the null id and assumes a new record must be inserted.
Could anyone perhaps provide some advice how can I solve this?

If required my struts.xml file is:

?xml version=1.0 encoding=UTF-8 ?
!DOCTYPE struts PUBLIC
-//Apache Software Foundation//DTD Struts Configuration 2.0//EN
http://struts.apache.org/dtds/struts-2.0.dtd;

struts
constant name=struts.enable.DynamicMethodInvocation value=false/
constant name=struts.devMode value=false/

package name=default namespace=/ extends=struts-default
action name=Menu
resultpages/firstpage.jsp/result
/action

 action name=user
resultpages/user/user_auth.jsp/result
/action

action name=admin
resultpages/admin/admin_auth.jsp/result
/action

action name=list method=execute class=org.user.PersonAction
result/pages/list.jsp/result
result name=inputpages/list.jsp/result
/action

action name=remove method=remove class=org.user.PersonAction 
result/pages/list.jsp/result
result name=inputpages/list.jsp/result
/action

action name=adduser
resultpages/user/Registration.jsp/result
/action

action name=save method=save class=org.user.PersonAction 
result/pages/list.jsp/result
result name=SUCCESSpages/list.jsp/result
/action

action name=edit

Re: trouble retrieving a request parameter with struts2 tags

2009-06-05 Thread Dave Newton

Dimitrios Christodoulakis wrote:

s:hidden name=person.id value=#attr.id label=Primary Key /


I told you #attr.id on javaranch; I meant #parameters. This information 
is readily available via the S2 docs. [1, 2]


IIRC the value attribute expects a literal; I'd wrap it in the OGNL 
escape, %{#parameters.id}, to make sure it's evaluated. Correct 
rendering is, of course, trivially verifiable by viewing the rendered 
source.


The fact remains that if person.id isn't being filled correctly by your 
Java code something is still wrong with it.



I have also tried unsuccessfully to retrieve the parameter value
from the action code, but always get null.


If I'm understanding what you're saying there then something is doubly 
wrong with either your config or your assumptions: there are several 
ways to retrieve URL parameters, and AFAIK they all work.


Note that the result named SUCCESS will never be used if you're using 
the ActionSupport convenience result constants.


Dave

[1] OGNL
http://struts.apache.org/2.x/docs/ognl.html

[2] OGNL Basics
http://struts.apache.org/2.x/docs/ognl-basics.html

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org