aspose file tools*
The moose likes Struts and the fly likes Setting the value in <s:textfield  from request scope Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Setting the value in <s:textfield  from request scope" Watch "Setting the value in <s:textfield  from request scope" New topic
Author

Setting the value in <s:textfield from request scope

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 757
Hi,

I want to set the value in textfield, the value is in requet scope.

how do i do it ?
i tried to use <s:property tag but i am not able to nest it in ><s:textfield tag.

my action class which sets the value in request is as bellow



and my jsp

on which i want to set the value is as bellow



Jigar Naik


Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 686


Hi,

You just remove request. from your text field tag.




And you will get the value.



Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

That's incorrect; OGNL expressions do not search JEE scopes. If a JSTL expression is used the request wrapper *will* search the value stack first *then* fall back to a scoped attr. The OGNL expression *would* require the request, but with a hash mark: #request.

The larger question is why do it this way at all? S2 provides an elegant mechanism making setting and using values like this in the request scope unnecessarily cumbersome--just make the values action properties:Then in the JSP:
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 757
Thanks David & Nishan.

Bellow worked... I found it by googling.



but i am not sure how it works... Can you please explain ? What do i get with "%" & "#"
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

%{} is the OGNL escape. The # means it's an action context "scope" variable, not on the stack.

Again--there's zero reason to do it like this, and at least a couple reasons not to.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting the value in <s:textfield from request scope