How to retain values in JSP using Struts2

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SaiRockinGuy
    New Member
    • Feb 2009
    • 11

    How to retain values in JSP using Struts2

    Hi,
    How to retain values in jsp using struts2 tags.

    I am using <s:select></s:select> which has inbuilt properties in it. But the values are not retained when the page gets refreshed.Can anyone help me in this.

    Thanks in advance!
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Do other values on that page retain their values?

    Comment

    • SaiRockinGuy
      New Member
      • Feb 2009
      • 11

      #3
      i dont have any text fields in that page, based on the drop down i get the list of employees and the current status of the employee.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Care to show the code?

        Comment

        • SaiRockinGuy
          New Member
          • Feb 2009
          • 11

          #5
          Code:
          <s:form action="control.action" method="Post">
          	<font color="orange"><s:text name="FILTRI" /></font>
          	<table style="border: solid 1px #777777;">
          		<tr>
          			<th align="left" class="cdr_label"><s:text name="CDR" /></th>
          		</tr>
          		<tr>
          			<td align="left"><s:select name="cdrList" headerKey="-1"
          				headerValue="Select"  listKey="employeeCode" listValue="description"
          
          				list="%{#session.EMPLOYEE_LIST}" /></td>
          			<td><s:submit cssClass="button_css" label="select"></s:submit></td>
          			
          		</tr>
          	</table>
          	</from>
          Last edited by Nepomuk; Feb 9 '09, 11:36 PM. Reason: Please use [CODE] tags

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Is </from> supposed to be </form>?

            Comment

            • SaiRockinGuy
              New Member
              • Feb 2009
              • 11

              #7
              Thanks, will check and ping

              Comment

              • SaiRockinGuy
                New Member
                • Feb 2009
                • 11

                #8
                Mean while can u help me for adding other option tag in <s:select></s:select> tag.

                My case is if the logged user is admin he should get the rights to view the entire drop down list or if normal user ,he can view only partial list.

                Comment

                • r035198x
                  MVP
                  • Sep 2006
                  • 13225

                  #9
                  Better do that on the server side. That is where the list is coming from isn't it?
                  You can then return the appropriate list based on who is logged in from the server side. Your front end (JSP) doesn't need to change for that.

                  Comment

                  • SaiRockinGuy
                    New Member
                    • Feb 2009
                    • 11

                    #10
                    Ya that is the better option but for other values in the drop down i have to send the other values as the key and for this case it is not so

                    Comment

                    • SaiRockinGuy
                      New Member
                      • Feb 2009
                      • 11

                      #11
                      actually i am adding two codes in the list key and passing it through request for other values in drop down

                      but for the value to be displayed for admin has different key.

                      Comment

                      Working...