Archive for July, 2007

For example, (Web design programs) we might set the header and

Thursday, July 19th, 2007

For example, we might set the header and footer values to: errors.header=

Validation Error

You must correct thefollowing error(s) before proceeding:

    errors.footer=

When the errors are written out to the HTML page, they’ll appear inside a bulleted list. Now that the Struts framework supports multiple MessageResources within the configuration file, you can specify which one should be used using the bundle attribute. 8.4.8 JavaScript Event Handlers Many of the HTML tags support JavaScript event handlers through the use of their attributes. For example, to configure an onClickhandler for a supported tag, you need to include the function name in the onClick attribute for the tag. Table 8-3 lists the attributes for the supported event handlers. Table 8-3. Attributes for the supported JavaScript event handlers Attribute Description onblur Executed when this element loses input focus. onchange Executed when this element loses input focus and its value has changed. onclick Executed when this element receives a mouse click. ondblclick Executed when this element receives a mouse double-click. onfocus Executed when this element receives input focus. onkeydown Executed when this element has focus and a key is depressed. onkeypress Executed when this element has focus and a key is depressed and released. onkeyup Executed when this element has focus and a key is released. onmousedownExecuted when this element is under the mouse pointer and a mouse button is depressed. onmousemoveExecuted when this element is under the mouse pointer and the pointer is moved. onmouseout Executed when this element is under the mouse pointer but the pointer is moved outside the element. onmouseoverExecuted when this element is not under the mouse pointer but the pointer is moved inside the element. onmouseup Executed when this element is under the mouse pointer and a mouse button is released. onreset Executed if the parent form is reset. onsubmit Executed if the parent form is submitted. 8.4.9 HTML Navigation Attributes Many of the tags also support navigation using only the keyboard. This is done using the attributes listed in Table 8-4.
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

Web site traffic - 8.4.5 The button and cancel Tags These two

Thursday, July 19th, 2007

8.4.5 The button and cancel Tags These two tags render HTML input elements of type button , populated from the specified value or from the content of the tag body. These tags are valid only when nested inside a form tag body. Stylesheets also can be used with these tags by supplying a value for the styleClass attribute. By default, the button label is set to the value “Click” and the cancel label is set to the value “Cancel”. You can override this using the value attribute. The button produced by the cancel tag has a special characteristic that causes the validate( ) method to be skipped when it’s pressed. The RequestProcessor just calls the execute( ) method, without going through the validation routine. 8.4.6 The checkbox Tag This tag renders an HTML input element of type checkbox, populated from the specified value or the specified property of the bean associated with the current form. This tag is valid only when nested inside a form tag body. The underlying property value associated with this field should be of type boolean, and any value you specify should correspond to one of the strings that indicate a true value (”true”, “yes”, or “on”). The browser will send values in the request only for those checkboxes that are checked. To correctly recognize unchecked checkboxes, the ActionForm bean associated with this form must include a statement setting the corresponding boolean property to false in the reset( ) method. 8.4.7 The messages and errors Tags These two tags are responsible for displaying a set of general-purpose messages or errors to the user. Messages correspond to ActionMessages, and errors to ActionErrors. The messages/errors are created either in the validate( )method or by the exception-handling framework. If no messages or errors are present, nothing will be rendered. When using the errors tag, the message bundle must include message keys for the following values: errors.header Text that will be rendered before the error messages list. Typically, this message text will end with

    to start the error messages list. errors.footer Text that will be rendered after the error messages list. Typically, this message text will begin with

to end the error messages list.
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

Web design careers - Because the name attribute is not specified in

Thursday, July 19th, 2007

Because the name attribute is not specified in the formtag, the tag will look up the signin action from the configuration file. It will retrieve the value of the name attribute from the action element and use that to check for an ActionFormin either the request or session scope. In this case, the loginForm will be selected because it’s the value for the name attribute in the action element. 8.4.3.4 The scope attribute The scopeattribute defines where the tag should look for the ActionForm. Its value must be either requestor session. If the scope attribute is not specified, it will be calculated by using the value of the actionattribute to look up the corresponding ActionMapping element, from which we will select the specified form bean scope. This is similar to how the name attribute is determined if it’s not specified in the form tag. 8.4.3.5 The type attribute The typeattribute specifies the fully qualified class name of the ActionForm to be created if no such bean is found in the specified scope. If this attribute is not specified, it will be calculated by using the value of the action attribute to look up the corresponding ActionMapping element, from which we will select the specified form bean type. 8.4.4 Using Multiple form Tags As with standard HTML, you can include more than one form tag within a JSP page. Obviously, only one form can be submitted at a time, but that doesn’t stop you from declaring multiple form tags. For example, you might have a formtag for a search area of the page. When the user presses the search button, that form is submitted along with the search criteria fields. In that same page, you might also have another form tag that performs a different function. When a button within that form is pressed, that form and its corresponding fields are submitted. Example 8-1 provides an example of what that might look like. Example 8-1. Using multiple form tags
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.

Business web site - The value for the actionattribute is used to

Wednesday, July 18th, 2007

The value for the actionattribute is used to select the ActionMapping the page is assumed to be processing, from which we can identify the appropriate ActionForm and scope. If extension mapping is being used (*.do), the actionvalue should be equal to the value of the path attribute of the corresponding action element, optionally followed by the correct extension suffix. An example of this is: If path mapping is used instead, the action attribute value should be exactly equal to the value of the path attribute of the corresponding action element: 8.4.3.2 The enctype attribute Typically, you won’t need to set the enctype attribute. However, if your form is performing file uploads, you should set the enctype attribute to multipart/form-data. You also must make sure the method attribute is set to POST, which is the default method if none is specified. 8.4.3.3 The name attribute The nameattribute specifies the name of the request- or session-scope ActionForm whose properties will be used to populate the input field values. If no such bean is found, a new bean will be created and added to the appropriate scope, using the Java class name specified by the type attribute. If no value is specified for the nameattribute, it will be calculated by using the value of the action attribute to look up the corresponding ActionMapping element, from which the form bean name will be determined. In other words, if no name attribute is specified for the form tag, the tag will use the value from the name attribute in the actionelement from the configuration file. This is a very important point that confuses many new Struts developers. Let’s look at an example. Suppose there is an action element configured like the following: Now say you have a formtag that looks like this declared in a JSP page:
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

This tag is very important when using relative (Affordable web hosting)

Wednesday, July 18th, 2007

This tag is very important when using relative URLs for images in a JSP page. There are no attributes associated with this tag. 8.4.3 The form Tag The Struts form tag is one of the most important tags in the HTML tag library. Its purpose is to render a standard HTML form tag and to link the HTML form with an ActionForm configured for the application. Each field in the HTML form should correspond to a property of the ActionForm. When an HTML field name and a property name match, the property from the ActionForm is used to populate the HTML field. When the HTML form is submitted, the framework will store the user’s input into the ActionForm, again matching up the HTML field names to the property names. All of the HTML custom tags that render HTML controls must be nested within the html tag. and its subclasses function the same way with the form tag. The formtag controls many important aspects of the page. Its attributes are shown in Table 8-2. Table 8-2. The form tag attributes Name Description action The URL to which this form will be submitted enctype The content encoding to be used when submitting this form. focus The field name to which initial focus will be assigned for this page. method The HTTP method that will be used to submit this request. name The name of the ActionForm whose properties will be used to populate the input field values. onreset The JavaScript event handler executed if the form is reset. onsubmit The JavaScript event handler executed if the form is submitted. scope The scope of the ActionForm for this form. style The CSS styles to be applied to this HTML element. styleClassThe CSS stylesheet class to be applied to this HTML element. styleId The identifier to be assigned to this HTML element. target The frame target to which this form is submitted. type The fully qualified class name of the ActionFormfor this page. 8.4.3.1 The action attribute
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.

Unlimited web hosting - password Renders a password input field radio Renders

Wednesday, July 18th, 2007

password Renders a password input field radio Renders a radio button input field reset Renders a reset button input field rewrite Renders a URI select Renders a select element submit Renders a submit button text Renders an input field of type “text” textarea Renders a textarea input field As was stated earlier, this chapter will not discuss every tag within the Struts framework; to do so would be redundant, as that material is covered thoroughly in the Struts JavaDocs. Instead, certain tags will be selected and discussed based on their importance, on how confusing they are to new developers, and on whether there are practical strategies for using the tags. If you need a reference to the complete set of available tags, you can find information in the Struts framework API documents at http://jakarta.apache.org/struts/api/. 8.4.1 The html Tag The htmltag renders an HTML html element. It allows you to include a locale attribute that will write out the user’s locale, assuming one has been stored into the session: 8.4.2 The base Tag This tag renders an HTML base element with an href attribute pointing to the absolute location of the enclosing JSP page. This tag is useful because it allows you to use relative URL references that are calculated based on the URL of the page itself, rather than the URL to which the most recent submit took place (which is what the browser normally would resolve relative references against). This tag must be placed within the HTML head element. The following is an example of using the basetag: The basetag example here would produce the following output when executed in the main page of the Storefront application:
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.

Web hosting reviews - setAddress(2, address) As you can see from these

Tuesday, July 17th, 2007

setAddress(2, address) As you can see from these examples, the subscripts used in indexed references are zero-relative (that is, the first element in an array is address[0]), just as is true in the Java language. 8.4 Struts HTML Tags The Struts HTML tag library contains tags used to create HTML input forms, as well as other tags generally useful in the creation of HTML-based user interfaces. For example, instead of using a regular HTML text-input field, you can use the texttag from this library. These tags are designed to work very closely with the other components of the Struts framework, including ActionForms. You always should attempt to use one of these tags first, rather than using standard HTML. These tags’ special knowledge of the rest of the Struts components makes it worthwhile to use them. Most of the tags within this library must be nested inside of a Struts form tag. There are a few tags included in this library that address issues not necessarily related to forms or form widgets. Those tags also will be discussed briefly in this section. Although not every HTML tag will be discussed, Table 8-1 provides a complete list of the tags that are available in the HTML tag library. Table 8-1. Custom tags within the Struts HTML tag library Tag name Description base Renders an HTML base element button Renders a button input field cancel Renders a cancel button checkbox Renders a checkbox input field errors Conditionally renders a set of accumulated error messages file Renders a file select input field form Defines an HTML form element frame Renders an HTML frame element hidden Renders a hidden field html Renders an HTML html element image Renders an input tag of type “image” img Renders an HTML img tag javascript Renders JavaScript validation based on the validation rules loaded by the ValidatorPlugInlink Renders an HTML anchor or hyperlink messages Conditionally displays a set of accumulated messages multibox Renders multiple checkbox input fields option Renders a select option options Renders a collection of select options optionsCollectionRenders a collection of select options
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Accessing (Web site construction) nested properties Accessing indexed properties

Tuesday, July 17th, 2007

Accessing nested properties Accessing indexed properties 8.3.1 Accessing Simple Properties Accessing simple bean properties works similarly to the JSP action. A reference to a property named “firstName” is converted into a method call to getFirstName( ) or setFirstName(value), using the standard JavaBeans specification naming conventions for bean properties. Struts uses the Java introspection APIs to identify the names of the actual property getter and setter methods, so your beans can provide customized method names through the use of a BeanInfoclass. See the JavaBeans specification, available at http://java.sun.com/products/javabeans/, for more information. 8.3.2 Accessing Nested Properties Nested references are used to access a property through a hierarchy of property names separated by periods ( . ), similar to the way that nested properties are accessed in JavaScript. For example, the following property reference: property=”user.address.city” is translated into the equivalent Java expression: getUser().getAddress().getCity( ) If a nested reference is used in a setter (such as when an input form is processed), the property setter is called on the last property in the chain. For the above property reference, the equivalent Java expression would be: getUser().getAddress( ).setCity(value) Nested properties are very convenient to use with custom tags. They almost always are used with the property attributes of the supported tags. 8.3.3 Accessing Indexed Properties Subscripts can be used to access individual elements of properties whose values are actually arrays, or whose underlying JavaBeans offer indexed getter and setter methods. For example, the following property reference: property=”address[2]” is translated into the equivalent Java expression: getAddress(2); while the same property reference in a setter would call the equivalent of:
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

There also is a fifth special library, called (Web site management)

Tuesday, July 17th, 2007

There also is a fifth special library, called the Nested tag library, that we’ll talk about separately later in this chapter. Earlier versions of the Struts framework contained a tag library called Form. It was replaced with the HTML tag library several versions ago, but form tags still sometimes show up in the documentation or example applications. The tags within a particular library perform similar or related functions. For example, the tags within the HTML tag library are used to render HTML presentation components inside HTML forms. There’s a tag to generate a checkbox, another for a button, and yet another to generate a hyperlink. 8.2.1 Using Tag Libraries with Struts Applications There’s nothing special about using the Struts tags they are like any other JSP custom tags. You must include the TLD declarations for each tag library you use in every page in which you need to use them. If you need to use the HTML and Logic tag libraries in a JSP page, for example, insert the following two lines at the top of the JSP page: <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> Once these lines are included and your web application deployment descriptor contains the necessary taglib elements, you can use the HTML and Logic tags within your JSP page. Continuing with the previous example, you need to add the following lines to your web.xml file: /WEB-INF/struts-html.tld /WEB-INF/struts-html.tld /WEB-INF/struts-logic.tld /WEB-INF/struts-logic.tld For more information on configuring the deployment descriptor for the web application, see Section 4.5 in Chapter 4. 8.3 Using JavaBeans with Struts Tags In many cases, you’ll use the tags from the various tag libraries in conjunction with JavaBeans. The JavaBeans may be ActionForms, whose properties correspond to input fields in the HTML form. In other cases, however, the beans will be ordinary value objects from the model layer. These beans can be in any scope: page, request, session, or application. There are three ways to access the properties of a JavaBean: Accessing simple properties
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

Web hosting mysql - Tag handler Tag library descriptor file

Monday, July 16th, 2007

Tag handler Tag library descriptor file The application deployment descriptor (web.xml) file The tag library declaration in the JSP page 8.1.3.2 Tag handler You’ve already been introduced to the tag handler. This is where the implementation of the tag is located. It’s a Java class that gets invoked at runtime and that performs some predefined behavior. 8.1.3.3 The TLD file The tag library descriptor (TLD) file is an XML file that contains meta-information about the tags within a library. Information such as the tag name, the attributes that are required, and the tag handler class name are all contained in this file and read in by the JSP container. 8.1.3.4 The web.xml file We discussed web application deployment descriptors in Chapter 3. Within this descriptor, you must define what tag libraries are being used in the web application and which TLD files should be used to describe each tag library. 8.1.3.5 The JSP page Obviously, the JSP page is a key component. It contains the include directives for one or more tag libraries, as well as the needed calls to the tag libraries within the JSP page. There is essentially no limit to how many tag libraries or tag references you can have in a JSP page. There have been some reports of sluggishness in JSP containers when the number of tags in a single JSP page approaches 40-50. Vendors have a lot of freedom in terms of how they initialize and process custom tags; some are better than others. If this becomes a problem for your implementation, you might try to redesign the page to reduce the number of tags, or combine some of the tags into a single handler. If that doesn’t solve your problem, run your tags in a different container and evaluate the performance. Attempting to cover all aspects of JSP custom tags is beyond the scope of this book. In fact, there are entire books written on the subject. A good source of information on custom tags and their use in applications is Hans Bergsten’s JavaServerPages (O’Reilly). 8.2 Tag Libraries Included with Struts The Struts framework provides a fairly rich set of framework components. It also includes a set of tag libraries that are designed to interact intimately with the rest of the framework. The custom tags provided by the Struts framework are grouped into four distinct libraries: HTML Bean Logic Template
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.