Tech I Enjoy Logo

Custom Search




  Home >> Struts

This example will try to cover steps for creating/rendering
Combo box with auto-complete type of functionality.

Using Struts 2 Plug in for DOJO, I will try to come up with
a screen / browser based UI for rendering static and or
dynamic values for any user input keys, and providing
auto complete type of functionality there-after.

There are some tags provided by Struts 2 and DOJO Plug in 
Tag Library, those can be used along with appropriate attribute
values will make this example to work with some sort of
dynamic values for the auto-completer to substitute and 
help in completing any user input being performed on the 
target UI component.

Let me show the Tag I have used in this example as follows:

<s2d:autocompleter id="fruitsList" name="fruitLists" label="Fruit you like most" loadOnTextChange="true" loadMinimumCount="1" preload="false" href="example/autopopulate" autoComplete="true"/> One can go through the official documentation for proper explaination for all the tags and its attributes, here I shall share what is my understanding so far on this topic, after of course running this example/POC on this technology.

id    : identified for the browser specific operation with this
       component.
name  : this goes to the server component as request parameter
label : visible Label on screen
loadOnTextChange : text change event notifier flag for this component
loadMinimumCount : minimum number of character(s)/letter(s) typed 
                   before notification is carried out.
preload : boolean flag for pre loading auto-completer values or not.
href : namespace/action mapping from the struts XML file, for
       getting the JSON Array containing the dynamic values.
autoComplete : flag for enabling auto complete or not.
Apart from all these attributes, there exist many more attributes those can be used as and when required. I have selected these attribute and this example is working as per my expectation with these attributes with values. The complete file sample.jsp
<%@ taglib uri="/struts-dojo-tags" prefix="s2d"%>
<html>
<head><title></title>
<s2d:head cache="true"/>
</head>
<body>
<div>
  <s2d:autocompleter id="example" 
             label="Automobile you like most" 
		     list="{'CAR', 'JEEP', 'LAND ROVER', 'TRUCK'}" />
  </br>
  <s2d:autocompleter id="fruitsList" name="fruitLists" 
                     label="Fruit you like most" 
		     loadOnTextChange="true" 
		     loadMinimumCount="1"  
             preload="false" href="example/autopopulate"
		     autoComplete="true"/>
</div>
</body>
</html>
Let's look at the struts.xml mapping file located under WEB-INF/classes folder: struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <package name="dojo-tree-example1" namespace="/example"
                 extends="struts-default">
        <action name="autopopulate" class="example.AutoPopulateAction">
          <result>/sample_autopopulate.jsp</result>
        </action>
    </package>
</struts>
AutoPopulateAction.java
package example;
import java.util.*;
import com.opensymphony.xwork2.ActionSupport;

public class AutoPopulateAction extends ActionSupport {
}
This action has nothing to do in this example, but one can write appropriate method and configure action mapping accordingly to execute this method. Now looking at this struts.xml file, there is a result mapping as "sample_auto populate.jsp" file. This file has a very selective work to perform, it just checks for the request parameter and depending on the request parameter value, appropriate JSON string/Array is passed as response, just to be displayed as auto completer suggestions/values on screen component. sample_autopopulate.jsp
<%
String listName = (String)request.getParameter("fruitLists");
%>
<% if(listName != null && listName.equalsIgnoreCase("m")) {%>
[ ["Mango"],["Mausombi"]]
<% } else if(listName != null && listName.equalsIgnoreCase("p")) {%>
[ ["Peach"],["Papaya"]]
<% } else if(listName != null && listName.equalsIgnoreCase("O")) {%>
[ ["Orange"]]
<% } else {%>
[ ["Mango"],["Mausombi"],["Peach"],["Papaya"],[Orange]]
<% } %>
I think , this is just one way of doing this perticular example in right order, but there are many other ways of doing this and any suggestion if you have, is always welcome in this web site, just drop us an email at usingframeworks@ gmail . com If anything missed out , please let me know at techienjoy at yahoo . com
List of Struts Example :
Examples List using Struts 2 and 
code explained.
Apache Struts with DOJO Example Part-3 :
Example of DOJO Toolkit with Struts and 
code explained.
Struts 2 Result Chain Example :
Example using Result Chain with Struts 2 and 
code explained.
Apache Struts 2 Validation With Expression :
Validation with Expression using Struts 2
and Example code explained.
Apache Struts 2 Tiles and I18N Example :
Example Steps of using Struts 2 With Tiles
and I18N code explained.
Struts 2 with JSF Example :
Example using JSF with Struts 2 and 
code explained.
Apache Struts 2 Tags Example :
Example of Struts 2 Tags and code explained.
Apache Struts 2 upload Example :
Uploading Example Steps of using Struts 2
and Example code explained.
Apache Struts 2 and XSLT With Example :
XSLT Example using Struts 2 and Example 
code explained.
Apache Struts 2 Example Steps :
Example Steps of using Struts 2 and code explained.
Struts 2 Tiles and I18N Example :
Example using Tiles and I18N with Struts 2 and 
code explained.
Apache Struts 2 PDF Result :
Example Steps of using Struts 2 with PDF Result
and code explained.
Struts Validation Example :
Example using Validation with Struts 2 and 
code explained.
Apache Struts 2 Custom Validator :
Example Steps of using Struts 2 with Custom Validator
and code explained.
Apache Struts with DOJO Example Part-1 :
Example of DOJO Toolkit with Struts and 
code explained.
Apache Struts 2 Tags Example :
Example Steps of using Struts 2 Tags
and code explained.
Apache Struts 2 Validation With Example :
Validation Example using Struts 2
and Example code explained.
Apache Struts Date Validation with Example :
Example of Date Validation using Struts and 
code explained.
Apache Struts with DOJO Example Part-4 :
Example of DOJO Toolkit with Struts and 
code explained.
Apache Struts 2 Validation Example :
Validation Example Steps of using Struts 2
and Example code explained.
Apache Struts with DOJO Example Part-2 :
Example of DOJO Toolkit with Struts and 
code explained.
Apache Struts 2 Result PlainText Example :
Example Steps of using Struts 2 PlainText Result
and code explained.
Struts 2 Plugin Example :
Example using Struts 2 Plugin
Apache Struts 2 Radio Tag Example :
Example Steps of using Struts 2 Radio Tags
and code explained.
Apache Struts Validation with Example :
Example of Validation using Struts and 
code explained.


References :
Tags: Struts 1 Struts2 plugin
Tags: struts jsf integrate
Tags: struts result chain
Tags: struts tiles i18n
Tags: Struts validation struggle
Tags: Struts
Tags: struts1 date validation
Tags: struts1 struts2 validation
Tags: struts2 dojo 1
Tags: struts2 dojo 2
Tags: struts2 dojo 3
Tags: struts2 dojo 4
Tags: Struts2 example steps Tag usage
Tags: Struts2 example steps
Tags: struts2 own validator
Tags: struts2 pdf result
Tags: struts2 radio tag example
Tags: struts2 result plaintext
Tags: struts2 tags example
Tags: struts2 tiles i18n
Tags: struts2 upload example
Tags: struts2 validation 1
Tags: struts2 validation expression
Tags: struts2 validation
Tags: struts2 xslt article



DISCLAIMER :
The content provided in this page is not warranted and/or guaranteed by techienjoy.com. 
techienjoy.com is not liable for any negative consequences that may result/arise from 
implementing directly/indirectly any information covered in these pages/articles/tutorials.

All contents of this site is/are written and provided on an "AS IS" basis,
without WARRANTIES or conditions of any kind, either express or implied, including, without
limitation, merchantability, or fitness for a particular purpose. You are solely responsible
for determining the appropriateness of using or refering this and assume any risks associated
with this.

In spite of all precautions taken to avoid any typo in these pages, there might be some 
issues like grammatical mistakes and typos being observed in these pages, techienjoy.com
extends sincerest apologies to all our visitors for the same.



Android Examples || Android Examples

© Copyright 2010-2012, TECHIENJOY, All Rights Reserved.      Privacy Policy     Disclaimer & Terms & Conditions