Announcement Announcement Module
Collapse
No announcement yet.
drop down box - validate page Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • drop down box - validate page

    Hi,

    I currently have a drop down box. I am using a AbstractWizardFormController and would like to know if its possible to retrieve the selected value in the Validatepage method?

  • #2
    Originally posted by Ellusionist
    would like to know if its possible to retrieve the selected value in the Validatepage method?
    If I understand you correctly, you can retrieve it like so:

    Code:
    protected void validatePage(Object o, Errors errors, int page) {
      YourCommandForm mcf= (YourCommandForm) o;
      String value = mcb.getSelectDropDownValue();
    }

    Comment


    • #3
      Here is the code:

      Code:
      <spring:bind path="activation.selectedAccount">	              
      	              <select id="selectedAccount" name="<c:out value="${status.expression}"/>"  onchange="submitForm(this.name);">
      	              	  <option value="0" >-- Select an account --</option>	
      		              <c:forEach items="${activation.associatedAccounts}" var="linkedAccount">
      	  					<option 
      		  					<c:if test="${linkedAccount.account.id == activation.selectedAccount}">selected</c:if>
      	  						value="<c:out value="${linkedAccount.account.id}"/>" >
      	  						<c:out value="${linkedAccount.account.accountKey}" />  					  	
      	  				  </option>
      					  </c:forEach>
      				  </select>	  
      				</spring:bind>
      The problem is that I need to get accountKey and not id (which is going into the form backing object).

      Comment


      • #4
        Originally posted by Ellusionist
        The problem is that I need to get accountKey and not id (which is going into the form backing object).
        In that case, I would look up the "accountKey" by iterating "activation.associatedAccounts" (assuming they're available in application/session scope) based on the "id" selected by the user. In other words, don't worry with passing "accountKey" as a param when you have the "id".

        Comment


        • #5
          Originally posted by socotech
          In that case, I would look up the "accountKey" by iterating "activation.associatedAccounts" (assuming they're available in application/session scope) based on the "id" selected by the user. In other words, don't worry with passing "accountKey" as a param when you have the "id".
          The "activation.associatedAccounts" is just a list containing the account numbers there is no way that I can link it at this stage of the form proccessing.

          Comment


          • #6
            Originally posted by Ellusionist
            Hi,

            I currently have a drop down box. I am using a AbstractWizardFormController and would like to know if its possible to retrieve the selected value in the Validatepage method?
            Have you considered using a propertyEditor to retrieve the account (for the specified id), so your form backing object would not have String: getSelectedAccountId() but rather Account:getSelectedAccount()?

            This post explains how to use property editors (it is actually for checkboxes, but it is still relevant): http://forum.springframework.org/sho...ght=checkboxes

            Comment

            Working...
            X