Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

struts 2 assigning value of property tag to hidden field

Tags:

struts2

I want to assign the value from field Description to a hidden field test. But the problem is the "Description" contains sequence of words and the following code is assigning only first word to "test"

<s:hidden value=<s:property value="Description" /> name="test">

I am kind of new to struts. Can someone please help. Also it would be nice if i get to know good tutorial links of struts2.

like image 928
saket Avatar asked Dec 16 '22 02:12

saket


2 Answers

If this is a property in your action class you need not to use <s:property value="Description" /> as the Description will be available at the top of value stack and you can use OGNL to fetch the value from value-stack.This is what you need to do

<s:hidden  value="%{description}" name="test" />

Please make sure the value in hidden filed should be similar to the name of property in your action class as it will be resolved to either the getter and setter in your action class or the public property defined in your action.

So this means value="%{description}" will be converted by OGNL like getDescription() and will try to find the getter in your action class to fetch the property value.

like image 97
Umesh Awasthi Avatar answered Feb 15 '23 18:02

Umesh Awasthi


<s:hidden  value="%{description}" name="test" />
like image 40
gooogenot Avatar answered Feb 15 '23 18:02

gooogenot