Results 1 to 4 of 4
  1. #1
    jigaramin13 is offline Member
    Join Date
    Apr 2010
    Location
    Vadodara
    Posts
    7
    Rep Power
    0

    Exclamation Need Help on jQuery and Struts2

    Hello ,

    I am working with Struts2 and jQuery.
    But I am able to add the Jquery datePicker widget with My Project.

    and Code Snap shot and Structure of the Wen-Content is as Follow :




    Directory Sructure for the Project is as Follows :

    Web-Content
    --images //it Contains Required Images.
    --js //contins js of jquery.
    ----jquery-1.4.2.min.js
    ----jquery-ui-1.8.custom.min.js
    --META-INF
    --theme
    ----... //Contins jquery control ui css.
    --ui
    ----jquery.ui.core.js
    ----jquery.ui.datepicker.js
    ----jquery.ui.widget.js

    --WEB-INF
    ----classes
    -------... //contains required action classes .class and validation.xml
    -------srtuts.xml
    ----LIB // Contains required libraries by Struts2 Framework
    ----SRC // Source code for Class Files .java files
    ----web.xmml
    --index.jsp
    --other jsp pages are here




    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

    <%@taglib prefix="s" uri="/struts-tags"%>
    <%@taglib prefix="sx" uri="/struts-dojo-tags" %>

    <html>
    <head>
    <sx:head/>
    <meta charset="UTF-8" />
    <title>jQuery UI Tabs - Default functionality</title>
    <link type="text/css" href="theme/jquery.ui.all.css" rel="stylesheet" />
    <link type="text/css" href="theme/jquery-ui-1.8.custom.css" rel="stylesheet" />
    <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
    <SCRIPT type="text/javascript" src="js/jquery-ui-1.8.custom.min.js"></SCRIPT>

    <script type="text/javascript" src="ui/jquery.ui.core.js"></script>
    <script type="text/javascript" src="ui/jquery.ui.widget.js"></script>
    <script type="text/javascript" src="ui/jquery.ui.datepicker.js"></script>

    <script type="text/javascript">
    $(function() {
    $("#datepicker").datepicker();
    });
    </script>
    </head>

    <body>
    <s:form action="HelloTest">

    <s:textfield name="firstName" label="Enter Your Name Here : " />
    <s:submit/>

    <!--This Struts2 DOJO Control to Select Date.-->
    <s:datetimepicker cssStyle="width:300px;" type="date" iconPath="images/calendar.gif" label="Date" displayFormat="dd/MMM/yyyy"> </s:datetimepicker>

    </s:form>

    <s:form>

    <!--Adding jQyery datetimecotrol Control To text area-->
    <s:textfield cssClass="datepicker" > </s:textfield>

    </s:form>
    </body>
    </html>

  2. #2
    jogep is offline Member
    Join Date
    Dec 2009
    Location
    Germany
    Posts
    43
    Rep Power
    0

    Default

    You reference in your JavaScript Code to an Element with an Id datepicker.
    But your textfield has no Id.

    You have 3 Options:

    1. Give your Textfield an Id
    Java Code:
    <s:textfield id="datepicker" cssClass="datepicker" > </s:textfield>
    2. Change your JavaScript form

    Java Code:
    $("#datepicker").datepicker();
    to

    Java Code:
    $(".datepicker").datepicker();

    3. Use the Datepicker Component form Struts2 jQuery Plugin

    I hope this helps you out

  3. #3
    jigaramin13 is offline Member
    Join Date
    Apr 2010
    Location
    Vadodara
    Posts
    7
    Rep Power
    0

    Default

    HI jogep,
    I got the Problem Solved
    Thanks a Lot For that.

    and Can you give me some good example of Struts2 with Validation

  4. #4
    jogep is offline Member
    Join Date
    Dec 2009
    Location
    Germany
    Posts
    43
    Rep Power
    0

    Default

    you can find many examples in the struts2 docs.

    Validation with XML
    Struts2 Validation

    Annotation based Validation
    Struts2 Validation with Annotations

    Best Regards

    Johannes Geppert

Similar Threads

  1. Struts2 jQuery Plugin
    By jogep in forum Java Software
    Replies: 7
    Last Post: 01-25-2011, 08:43 PM
  2. struts2 with jquery
    By amma2009 in forum Advanced Java
    Replies: 10
    Last Post: 11-16-2010, 09:07 AM
  3. Need JQuery PDF Tutorials
    By vinothkumarrvk in forum Web Frameworks
    Replies: 1
    Last Post: 04-09-2010, 05:47 PM
  4. Need JQuery PDF Tutorials
    By vinothkumarrvk in forum Forum Guides
    Replies: 0
    Last Post: 03-05-2010, 03:22 PM
  5. jQuery 1.2.1
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 10-25-2007, 04:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •