You are viewing a plain text version of this content. The canonical link for it is here.
Posted to tdk-dev@turbine.apache.org by jv...@apache.org on 2001/05/22 23:20:21 UTC

cvs commit: jakarta-turbine-tdk/src/share/velocity/peer/templates/jsp/tld Test.tld

jvanzyl     01/05/22 14:20:21

  Added:       src/share/velocity/peer/WEB-INF/src/tags UserInfoTag.java
               src/share/velocity/peer/templates/jsp/screens Index.jsp
                        Login.jsp
               src/share/velocity/peer/templates/jsp/tld Test.tld
  Log:
  - adding jsp example
  
  Revision  Changes    Path
  1.1                  jakarta-turbine-tdk/src/share/velocity/peer/WEB-INF/src/tags/UserInfoTag.java
  
  Index: UserInfoTag.java
  ===================================================================
  package @TARGET_PACKAGE@.tags;
  
  import java.io.IOException;
  
  import javax.servlet.jsp.tagext.TagSupport;
  import javax.servlet.jsp.JspException;
  import javax.servlet.jsp.PageContext;
  
  import org.apache.turbine.util.RunData;
  import org.apache.turbine.services.jsp.JspService;
  import org.apache.turbine.om.security.User;
  
  /**
   * UserInfoTag is a sample JSP tag handler that displays the full
   * name of the user that is currently logged in.
   */
  
  public class UserInfoTag extends TagSupport
  {
    /**
     * Process the StartTag event
     *
     * @exception JspException
     */
  
    public int doStartTag() throws JspException
    {
  
      // Get the Turbine "RunData" object that was stuffed into the Http request.
  
      RunData data = (RunData)pageContext.getAttribute(JspService.RUNDATA, PageContext.REQUEST_SCOPE);
  
      // If we have a RunData object, get the User object
  
      if (data != null)
      {
        User user = data.getUser();
  
        // Write out the user's full name (last name, first name)
  
        try
        {
          String fullName = user.getFirstName() + " " + user.getLastName();
          pageContext.getOut().print(fullName);
        }
        catch (IOException e)
        {
          throw new JspException("I/O Exception: " + e.getMessage());
        }
      }
  
      return SKIP_BODY;
    }
  }
  
  
  
  1.1                  jakarta-turbine-tdk/src/share/velocity/peer/templates/jsp/screens/Index.jsp
  
  Index: Index.jsp
  ===================================================================
  <%@ taglib uri="/WEB-INF/tlds/Test.tld" prefix="tags" %>
  
  <html>
  <head>
  <title>Index.jsp</title>
  </head>
  
  <body>
  Hello <tags:UserInfo/>.
  </body>
  
  </html>
  
  
  1.1                  jakarta-turbine-tdk/src/share/velocity/peer/templates/jsp/screens/Login.jsp
  
  Index: Login.jsp
  ===================================================================
  <html>
  <head>
  <title>Login</title>
  </head>
  
  <body>
  
  <blockquote>
  
  <form method="post">
    <input type="hidden" name="Action" value="LoginUser">
  
    <table>
    <tr>
    <td>Username</td>
    <td><input type="text" name="username"></td>
    </tr>
  
    <tr>
    <td>Password</td>
    <td><input type="password" name="password"></td>
    </tr>
  
    <tr>
    <td>&nbsp;</td>
    <td><input type="submit" value="Login"></td>
    </table>
  
  </form>
  </blockquote>
  
  </body>
  </html>
  
  
  1.1                  jakarta-turbine-tdk/src/share/velocity/peer/templates/jsp/tld/Test.tld
  
  Index: Test.tld
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1" ?>
  <!DOCTYPE taglib PUBLIC 
    "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" 
    "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"> 
  <taglib>
    <tlibversion>1.0</tlibversion>
    <jspversion>1.1</jspversion>
    <shortname>Tags</shortname>
  
    <tag>   
      <name>UserInfo</name>
      <tagclass>com.planetcad.suitex.UserInfoTag</tagclass>
      <bodycontent>empty</bodycontent>
    </tag>
  </taglib>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-tdk-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-tdk-dev-help@jakarta.apache.org