2

How to set propety value in <s:textfield>

I tried <s:textfield name="customerName" label="Customer Name" value='<s:property value="userInfo.customerName"' /> but it didn't work.

Please help

Lohit
  • 891
  • 5
  • 14
  • 26

3 Answers3

17

You can not use a tag inside of a tag. Use OGNL instead!

<s:textfield name = "customerName" 
            label = "Customer Name" 
            value = "%{userInfo.customerName}"/>
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
Johannes
  • 2,060
  • 3
  • 17
  • 27
0

Use OGNL (Object Graph Navigation Language) to get value in any kind of field of struts. If you will not get value please check setter and getter of the variable.

<s:textfield name="transValueChange" id="transValueChange" 
             value ="%{transValue}" theme="simple" maxLength="30"
             onkeypress="return isNumberKey(event)">
</s:textfield>

OR

<s:select name="propCode" id="propCode" list="propClassMasMap" theme="simple"
          value="%{propCode}" onchange="" cssClass="text">
</s:select>
Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
Ravi Thapa
  • 79
  • 1
  • 7
0

I used this:

<table>
    <s:label>User Name:</s:label>
    <s:textfield name="user.userid" cssClass="tb5" type="text" placeholder="User Name" value="%{#session.userid}" disabled="true" /> 
</table>

The disabled attribute is not mandatory, I used it to disable the textfield that way the values will be retrieved from the DB and will be disable for the user to make changes on it.

Pokechu22
  • 4,984
  • 9
  • 37
  • 62
S. Mayol
  • 2,565
  • 2
  • 27
  • 34