| |
Struts Tutorials:
Struts2 Tag CheckBoxList , Checkbox, Iterator, IF
Struts2 Tag Library Example
Struts2 Tiles Example
Struts2 Tiles I18N Example
Struts2 Questions
Struts Tiles I18N Example
Struts Eclipse MVC
Struts2 Tags
Struts2 Example and Tutorial
Struts MVC
Struts2 Validation
Hibernate Tutorials:
Hibernate Case Study
Class Hierarchy Persist Example
Using Hibernate Interceptor
Hibernate Questions with Answer
Hibernate Many-to-Many Mapping Example
Hibernate one-to-many Mapping Example
Hibernate and ORM tools
Spring Hibernate Example
Hibernate SessionFactory Example
Hibernate Mapping Class Hierarchy
Hibernate Questions
Hibernate SessionFactory Questions
Spring Hibernate Example:
Spring Hibernate Case Study
Written By : Amit
Title :
MVC Struts
Description :
Some facts about MVC Framework and Struts More...
|
Written By : Amit
Title :
Struts2 example tutorial
Description :
My First example using Apache Struts2 More...
|
Written By : ISHTEK
Title :
Struts2
Description :
Tags such as IF Iterator Tags More...
|
Written By : guddu
Title :
Struts Eclipse MVC
Description :
Step by step demonstration More...
|
Written By : Girish
Title :
Struts Tiles I18N Example
Description :
Code with Sample Action More...
|
| Tags/Keywords : Struts, Struts2 Tutorial, Struts 2 Example, Struts2 Author : ISHTEK Date (Year/Month/Date): 2010-05-30
Using DOJO Tag along with Struts 2 Plugin - Combobox AutoCompleter | |
Please be informed that NONE of the design/code/matter from this page is claiming to be some
sort of best practice and we DO NOT expect any of our visitor/reader of this page to assume
this as some sort of best practice for any context and should not be using this as it is
without appropriate evaluation.
This page intends only to provide bits and pieces of known ways for doing some sort of example
and may not be fit for any other purpose.
In spite of all precautions taken to provide accurate and avoid any typo in these pages,
there might be some issues like grammatical mistakes and typo being observed in these pages,
We extend our sincerest apologies for the same.
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 particular example
in right order, but there are many other ways of doing this
and any suggestion is always welcome.
|
|
|
|
| Home >>> Struts Struts 2 Example Tutorial >>> Struts2 And DOJO >>> Auto Completer Example Dynamic AJAX |
|
|
Visitor/User referred related external URL:
(Visible upon review and approved by this site Administrator)
|
|
|
|
|
<- requires login | Log in or Register | |
Copyright © 2008-2010, Interview-Questions-Tips-Forum, All Rights Reserved. | CONTACT PRIVACY POLICY DISCLAIMER |
| |  |
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
Other names may be trademarks of their respective owners
This web site's Terms of Use and Disclaimer :
This web site provides some of the information about various technologies, example code, tips, tutorials etc. Like any printed materials,
content of these pages may become out of date over a period of time. Therefore all visitor/users of this web site are requested/advised
to refer to the originating parties/sources for the latest changes and happenings for detailed information. This information is not
intended to be a substitute for the original reference provided by the originating parties/sources. These examples with source code or
without source code, have not been thoroughly tested under all conditions. Interview-questions-tips-forum.net therefore, cannot guarantee
or imply reliability of these example source code or programs.
By accessing and using this website in any ways, including, without limitation, browsing the website pages, using any information, using
any content and/or downloading any materials, you agree to and are bound by the terms of use described in this page and Usage Terms and Conditions.
If you do not agree to all of the terms and conditions contained in the terms of use described in this page and
Usage Terms and Conditions, do not use this website in any manner. If you are using the website on behalf of your
employer, you represent that you are authorized to accept these Terms of Use on your employer's behalf.
All Trademarks are property of their respective owner. Appropriate measure is being taken for providing accurate and up-to-date
information but like any printed materials, these blog(s)/contents may eventually be outdated one day, so if you are using any of these
information, please refer original content/documentation from respective sources. And under no circumstances shall the Author of these
contents and/or this web site be liable for any loss, damage, expense incurred or suffered which is claimed to have occurred because of
usage of the contents of this web site. If you have any questions/queries/feedback/suggestions then please write to this web site owner
at contact.
|  |
|
|
|
|
|