Showing posts with label dojo plugin. Show all posts
Showing posts with label dojo plugin. Show all posts

Sunday, April 23, 2017

Set default selected value in struts2 select tag

Setting selected date in dojo date picker using struts2.

Add the code below in jsp file.
      <!--name attribute inside select tag must be a variable in action class with getter/setter -->  
      <!-- test variable sets the value of selected item in action class -->  
      <select name="test">  
           <!-- name attribute could be anything you want but value attribute must be a model class variable-->  
           <s:set name="lead_string_LS_ID" value="MasterDataModel.string_LS_ID" />  
                <!-- value attribute must be a list to iterate, status (an instanceof IteratorStatus will be pushed into stack upon each iteration)or result -->  
                <!-- var Name used to reference the value pushed into the Value Stack (my list contain leadSource_String_Id)-->  
                <s:iterator value="leadSource_list" status="result" var="leadSource_String_Id">  
                          <!--#lead_string_LS_ID is value taken from <set> tag above. Note # must be in-front of the name  
                               leadSource_String_Id is element specified in var of <iterator> tag       
                          -->  
                          <s:if test='(#lead_string_LS_ID.equals(leadSource_String_Id))'>  
                               <option value="<s:property value='leadSource_String_Id'/>" selected="selected">  
                                    <s:property value="leadSource_String_Name" />  
                               </option>  
                          </s:if>  
                          <s:else>  
                               <option  
                                    value="<s:property value='leadSource_String_Id'/>">  
                                    <s:property value="leadSource_String_Name" />  
                               </option>  
                          </s:else>  
                </s:iterator>  
      </select>  

SQL INTERVIEW QUESTIONS AND ANSWERS