Solved

Dojo Form to Spring

Posted on 2009-07-16
1
2,333 Views
Last Modified: 2013-11-11
Hi there,

I am new to dojo and spring. Recently I developed sample login code where the user enters user id and password to login. My code is working fine when I hard code the value and send it DB from Spring-->Hibernate.

But I am having problem in sending the parameters through user interface by AJAX calls and getting the response, I can't  send the request and get the response I am using DOJO framework for my front end.
<html>----
 

</script>

        <script type="text/javascript">

        

              function validate(value){

              var userId = dijit.byId("userId").getValue();

              if(userId == ""){

              console.log("UserName is empty");

              return;

              }

              var pswd = dijit.byId("pswd").getValue();

                if(pswd == ""){

              console.log("Password is empty");

              return;

              }

              return;

             };

function send(){

var userName = dijit.byId("userId").getValue();

dojo.xhrGet({

url: "hello.jhtml?userName=" +userName,

formName: "loginForm",

handleAs: "text",

handle: validationResponse,

error: Error

});

}

function Error(data, ioArgs) {

       alert("in the error function");

};

function reset(){

dijit.byId("userId").getValue()="";

dijit.byId("pswd").getValue()="";

};

</script>

<div id="dialog" title="Login" style="width:275px;height:85px;padding:10px;margin:10px;border:solid rgb(200,200,200) 1px;">

<!--      <form:form commandName= "loginForm" action="hello.jhtml" method="post" id="loginForm" >-->

        <div id="mainLoginHeader">

<div id="subLoginHeader">

<b>Please enter a valid user id</b>

</div>

<!-- End of subLoginHeader -->

<div class="spacing-div_10X0"/></div>   

<div id="userId">

          <b><label id="userId">User Id:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </label></b> 

          <input type="text" 

          name="login" 

          id="userId"

          tabindex="1"

          class="dijitInputField dijitInputFieldValidatorError dijitFormWidget"

          widgetId=userId"

          size="20"

          dojoType="dijit.form.ValidationTextBox" 

          trim="true"

          required="true"

          promptMessage="Enter the User ID"

          invalidMessage="User ID is required"

          onChange="validate(this.value)"

           />

	</div>

	<!-- End of userId -->

	<div id="userIdErrorMsg" dojoType="dijit.Tooltip">

	<input type="text"></div>

	<form:errors></form:errors>

	

<div class="spacing-div_5X0"/></div>   

<div id="pswd">     

          <b><label id="pswd">Password: </label></b>

          <input type="password" 

          name="login" 

          id="pswd"

          tabindex="2"

          class="dijitInputField dijitInputFieldValidatorError dijitFormWidget"

          widgetId=userId"

          size="20"

          dojoType="dijit.form.ValidationTextBox" 

          trim="true"

          required="true"

          promptMessage="Enter the Password"

          invalidMessage="Password is required"

          onChange="validate(this.value)"

           />

	</div>

	<!-- End of pswd -->

	<div class="spacing-div_5X0"/></div>

        <!-- button ok -->  

 <div id="Button" align="right">       

          <button dojoType="dijit.form.Button" type="submit" id="LoginButton" 

 onclick="send()">Log In</button>
 
 

 dispatcher-servlet.xml
 

  <bean id="loginFormController" name="/hello.html" class="LoginFormController">

   <property name="formView" value="jsp/main.jsp"/>  

 <property name="successView" value="success.jsp"/>  

 <property name="loginControllerService">

 <ref local="loginControllerService"/> 

 </property>

 <property name="validator">  

            <bean class="LoginValidator"/>  

        </property>  

  

</bean>
 

<bean id="loginControllerService" class="LoginController"> 

</bean>

Open in new window

0
Comment
Question by:theartha
1 Comment
 
LVL 20

Accepted Solution

by:
Sathish David  Kumar N earned 500 total points
ID: 24923727
dont use same id name !
in dojo they didnt accept same id name ...

in your code div id ="userId"  user input id also same so rename the id ..
0

Featured Post

Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What is the cheapest way to learn Websphere MQ? 2 74
countHi2 challenge 7 52
PHP Curl Setup Option 4 54
Problem to start Neon 20 83
Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now