2

Hello friend I am trying to write Decryption value expression into s:textfield value"<%=custFirstName%>" something like this but it give me an error i.e According to TLD or attribute directive in tag file, attribute value does not accept any expressions so what is the alternate way to do same thing in . Please help me out. in INPUT type its working well but i want to do it same thing through struts tage.

This is my code

    <s:iterator value="userList">
        <s:set var="custFirstName" value="custFirstname"/>
        <s:set var="custLastName" value="custLastname"/>
        <s:set var="custEmail" value="custEmail"/>
        <s:set var="custPhone" value="custPhone"/>
        <s:set name="custVerified" value="custIsVerified"/>
        <%
        String custFirstName = pageContext.getAttribute("custFirstName").toString();
        String custLastName = pageContext.getAttribute("custLastName").toString();
        String custEmail = pageContext.getAttribute("custEmail").toString();
        String custPhone = pageContext.getAttribute("custPhone").toString();

        Encryption encryption=new Encryption();
        custFirstName = Encryption.decString(custFirstName);
        custLastName = Encryption.decString(custLastName);
        custEmail = Encryption.decString(custEmail);
        custPhone = Encryption.decString(custPhone);
    %>




            <td> <s:textfield value="<%=custFirstName%>" label="First Name"/></td>
            <%-- <input type="text" value="<%=custFirstName%>" > --%>
            <td> <s:textfield name="custLastName" label="Last Name"/></td>
            <td> <s:textfield name="custEmail" label="Email"/></td>
            <td> <s:textfield name="custPhone" label="phone"/></td>
            <td> <s:textfield name="custCountry" label="Country"/></td>
            <td> <s:textfield name="custState" label="State"/></td>
            <td> <s:textfield name="custCity" label="City"/></td>
            <s:submit value="Update"></s:submit>

    </s:iterator>   

</s:form>



<input type="text "value="<%=custFirstName%>">

and I want to write above input value expression into s:textfield value="" how I can do it.

Roman C
  • 49,761
  • 33
  • 66
  • 176
Harshit
  • 153
  • 1
  • 11

2 Answers2

0

You could use something like:

<td> <s:textfield value="%{#custFirstName}" label="First Name"/></td>
SMA
  • 36,381
  • 8
  • 49
  • 73
  • I used this also but it shows me Encrypted value not decrypted value – Harshit Dec 24 '14 at 08:44
  • Bring your c:set tag after you decrypt the values so they reflect decrypted values rather than encrypted ones. – SMA Dec 24 '14 at 08:46
  • Did you use `<%=custFirstName%>` after descrypting? If not do this and its the right way of assigning the value. – SMA Dec 24 '14 at 09:09
  • Yes it was a valid question and good thing was it was formatted and well explained. So +1. – SMA Dec 24 '14 at 10:01
0

You needed to set the value attribute, that's right, but it should be OGNL expression.

Encryption encryption=new Encryption();
custFirstName = Encryption.decString(custFirstName);
custLastName = Encryption.decString(custLastName);
custEmail = Encryption.decString(custEmail);
custPhone = Encryption.decString(custPhone);
ValueStack vs = ActionContext.getContext().getValueStack();
vs.set("custFirstName", custFirstName);
vs.set("custLastName", custLastName);
vs.set("custEmail", custEmail);
vs.set("custPhone", custPhone);

and then you can use OGNL

<s:textfield name="custFirstName" value="%{#custFirstName}" label="First Name"/>

...

You might also look this Struts 2 Value Stack/OGNL.

Roman C
  • 49,761
  • 33
  • 66
  • 176