ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clinton Begin" <clinton.be...@gmail.com>
Subject RE: iBATIS+Sprites problem !!!!!
Date Wed, 06 Feb 2008 14:09:38 GMT
Satya,

This is a question for the Stripes mailing list.


Clinton

-----Original Message-----
From: satya_08 [mailto:sb.majumder@rediffmail.com] 
Sent: February-06-08 2:58 AM
To: user-java@ibatis.apache.org
Subject: iBATIS+Sprites problem !!!!!


Hi all , I am a beginer in iBATIS and sprites .

I am trying to develop a small web application ,

Here is the structure of my app------------->
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\TestStripes
There is a jsp file , 
under C:\Program Files\Apache Software Foundation\Tomcat
5.5\webapps\TestStripes directory .

The content of the jsp is 
****************************************************************************
***
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="stripes"
uri="http://stripes.sourceforge.net/stripes.tld"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
      <title>LOGIN PAGE</title>
      <style type="text/css">
          input.error { background-color: yellow; }
      </style>
  </head>
  <body>
                              <h1>UserID and LOGIN</h1>



    <stripes:form action="/user_validation/UserPass.action" focus="">
        <stripes:errors/>
        <table>
            <tr>
                <td>User ID:</td>
                <td><stripes:text name="user_id"/></td>
            </tr>
            <tr>
                <td>Password:</td>
                <td><stripes:password name="password"/></td>
            </tr>
            <tr>
                <td colspan="2">
                    <stripes:submit name="submit_action" value="submit"/>
                </td>
            </tr>
            <tr>
                <td>Result:</td>
                <td>${actionBean.result}</td>
            </tr>
        </table>
    </stripes:form>
  </body>
</html>

****************************************************************************
***
Under WEB-INF , there are two sub directory 
   1)lib
   2)classes
   Under lib I have included all the necessary jars , such as
:commons-logging.jar,cos.jar,ibatis-3.0.677.jar,
   jstl.jar,log4j-1.2.9.jar,mysql-connector-java-5.0.4-bin.jar,standard.jar
& stripes.jar

  Under classes directory there is my UserPassActionBean.java file and
SqlMapConfig.xml and SqlMap.xml files   

The UserPassActionBean.java  is ----------->
****************************************************************************
***

   package net.sourceforge.stripes.user_validation;

   import net.sourceforge.stripes.action.ActionBean;
   import net.sourceforge.stripes.action.ActionBeanContext;
   import net.sourceforge.stripes.action.DefaultHandler;
   import net.sourceforge.stripes.action.Resolution;
   import net.sourceforge.stripes.action.StreamingResolution;
 //  import net.sourceforge.stripes.validation.Validatable;
   import net.sourceforge.stripes.validation.ValidationError;
   import net.sourceforge.stripes.validation.ValidationErrorHandler;
   import net.sourceforge.stripes.validation.ValidationErrors;
   import net.sourceforge.stripes.action.ForwardResolution;
   
   
   import com.ibatis.sqlmap.client.*;
   import com.ibatis.common.resources.Resources;
   import com.ibatis.common.logging.*;


   import java.io.StringReader;
   import java.util.List;
   import java.io.*;
   import java.util.*;

   public class UserPassActionBean implements ActionBean,
ValidationErrorHandler
   {
              private ActionBeanContext context;
             /* @Validate(required=true) */private String user_id;
            /*  @Validate(required=true) */private String password;
                                           private String result;

              public ActionBeanContext getContext() { return context; }
              public void setContext(ActionBeanContext context) {
this.context = context; }

              public Resolution handleValidationErrors(ValidationErrors
errors) throws Exception
              {
                       StringBuilder message = new StringBuilder();
                       for (List<ValidationError> fieldErrors :
errors.values())
                       {
                             for (ValidationError error : fieldErrors)
                             {
                                message.append("<div style=\"color:
firebrick;\">");
                               
message.append(error.getMessage(getContext().getLocale()));
                                message.append("</div>");
                             }
                       }
                       return new StreamingResolution("text/html", new
StringReader(message.toString()));
              }
              /** Handles the 'submit' event, check the validation  and
returns the result. */
          /*    @DefaultHandler public Resolution submit()
              {
                  String result = String.valueOf(user_id + password);
                  return new StreamingResolution("text", new
StringReader(result));
              } */

              // Standard getter and setter methods
              public String getUser_id() { return user_id; }
              public void setUser_id(String user_id) { this.user_id =
user_id; }

              public String getPassword() { return password; }
              public void setPassword(String password) { this.password =
password; }
              public String getResult() { return result; }
              public void setResult(String result) { this.result = result; }

              /** An event handler method that adds number one to number
two. */
              @DefaultHandler
              public Resolution submit()
              {
                  
                  try
                  {
                       String resources = "SqlMapConfig.xml";
                       Reader reader =
Resources.getResourceAsReader(resources);
                       SqlMapClient sqlMapper =
SqlMapClientBuilder.buildSqlMapClient(reader);
                       Map m = new HashMap(1);
                       m.put("a",user_id);
                       password =
(String)sqlMapper.queryForObject("out_example",m);
                       result = user_id + password;
                  }
                  catch(IOException ex)
                  {
                      // System.out.println(ex.getMessage());
                        ex.printStackTrace();
                  }
                  catch(Exception ex)
                  {
                     // System.out.println(ex.getMessage());
                      ex.printStackTrace();
                  }   
                   return new ForwardResolution("/index.jsp");
              }


   }
****************************************************************************
***
The content of the sqlMap.xml is 
****************************************************************************
***
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap      
    PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"      
    "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap>

<parameterMap id="pm_out_example" class="java.util.Map">
   <parameter property="a" mode="IN" />
</parameterMap>
<procedure id="out_example" parameterMap="pm_out_example"
                            resultClass="String">
{call usp_sel_ggl_users_passwd(?)}
</procedure>

</sqlMap>

****************************************************************************
***
& the content of the SqlMapConfig.xml is 
****************************************************************************
***
<?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE sqlMapConfig
      PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
      "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">

  <sqlMapConfig>
     

      <!-- Statement namespaces are required for Abator -->
      <settings useStatementNamespaces="true" />

      <!-- Setup the transaction manager and data source that are
          appropriate for your environment-->
      <transactionManager type="JDBC">
          <dataSource type="SIMPLE">

              <property name="JDBC.Driver" value="com.mysql.jdbc.Driver" />
              <property name="JDBC.ConnectionURL"
value="jdbc:mysql://189.160.100.72/_db" />

              <property name="JDBC.Username" value="root" />
              <property name="JDBC.Password" value="sql123" />
          </dataSource>
      </transactionManager>

      <!-- SQL Map XML files should be listed here -->
      <sqlMap resource="SqlMap.xml" />

         

  </sqlMapConfig>

****************************************************************************
***
Now when I upload my entire application into web & when I am invoking the
jsp its ok , but when I give some values into the text field , & pressing
the submit button the jsp does not give any output .

Please help me out from this problem 

Thanks 

Satya
-- 
View this message in context:
http://www.nabble.com/iBATIS%2BSprites-problem-%21%21%21%21%21-tp15306350p15
306350.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Mime
View raw message