Search on the blog


Learn Struts(1)

For some reason, I decided to learn a popular Java MVC framework "Struts." Maybe it's because I'm now engaged in a project concerning the framework, or maybe I just think that I should be familiar with at least one famous framework...

Anyway let's get started. This is the first day, so I'll start it with an easy task.

How does the focus property in html:tag work?

I just created a simple jsp and checked it.
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="" prefix="html"%>
<title>HTML Tags Test</title>
<html:form action="/auth" focus="id">
    ID: <html:text property="id" size="16" /><br/>
    PASS: <html:text property="pass" size="16" /><br/>
    <html:submit property="submit" value="submit" />
    <html:reset value="reset" />
The above JSP yields the following HTML:
<title>HTML Tags Test</title>
<form name="testForm" method="post" action="/struts/">
    ID: <input type="text" name="id" size="16" value=""><br/>
    PASS: <input type="text" name="pass" size="16" value=""><br/>
    <input type="submit" name="submit" value="submit">
    <input type="reset" value="reset">
<script type="text/javascript" language="JavaScript">
  var focusControl = document.forms["testForm"].elements["id"];

  if (focusControl != null && focusControl.type != "hidden" && !focusControl.disabled && != "none") {
  // -->

It added some javascript code. So this is how it works.

0 件のコメント: