Struts 2.1 Assigning a property to a JSP variable

2009-06-25 Thread gdown
Does anyone know how to assign a value from s:property to a JSP variable? I'm trying to do something like this (I know this doesn't work): % String prodType = s:property value=productType/; % We're migrating a struts 1.0.2 app to 2.1 and we have a lot of code that used to access the

Struts 2.1 Accessing the action instance from a JSP

2009-06-25 Thread gdown
Does anyone know how to access the action instance from the value stack. I'd like to be able to call a method on the action from the JSP. I'm trying to do something like this: MyAction.java: public class MyAction extends ActionSupport { public String myMethod() { return

Re: Struts 2.1 Accessing the action instance from a JSP

2009-06-25 Thread gdown
I was able to get access to the action from the JSP as follows (it isn't pretty but it worked) JSP: % com.opensymphony.xwork2.ognl.OgnlValueStack stack = (com.opensymphony.xwork2.ognl.OgnlValueStack)request.getAttribute(struts.valueStack); MyAction myAction = (MyAction)stack.findValue(action);

Re: Struts 2.1 Assigning a property to a JSP variable

2009-06-25 Thread gdown
Well I found 2 ways to assign an action's property to a JSP variable in a scriptlet: Solution 1: Set property as an attribute JSP: s:set scope=request var=prodType value=productType/ % String myProductType = request.getAttribute(prodType) % This takes the action's productType property and

Dynamic value supplied s:text name in struts 2

2009-06-25 Thread gdown
With Struts1 the following would work: JSP: % String productType = [get the productType from the form] String productTypeI18nKey = product.type.list. + productType; % html:text property=%=productTypeI18nKey%/ With the Struts2, how would I do the same. I've tried: JSP: % String

Re: Dynamic value supplied s:text name in struts 2

2009-06-25 Thread gdown
Correction on this question. With Struts1 the following would work: JSP: % String productType = [get the productType from the form] String productTypeI18nKey = product.type.list. + productType; % bean:message key=%=productTypeI18nKey%/ With the Struts2, how would I do the same. I've tried: