Posts (page 2)
I noticed that when I used the CollapsiblePanelExtender, it had a tendancy to flicker once when the page loads. Here is my quick fix for that. All you have to do is add these properties to the panel's definition:
style="overflow:hidden" Height="0"
I hope this helps.
This would be the first personal update I have posted online in months. There is a lot to cover, but I am not interested in boring my readers so I will cover it quickly.
First, I moved to Portland (for those who don't know). My aspirations haven't changed much, but I am now employed at Louisiana Pacific Corporation.
I am getting married in October. For those of you who are invited, I can't wait to see you there. For those of you who haven't received invitations fear not. I haven't sent invitations as of yet.
I decided to use VOX for the time being simply because of the power. I will aggregate all of my blog posts to my site in the near future, but for now, I am back.
Vox has been great to me, but I am migrating my blog to my own personal site. www.cyberkruz.com.
This tutorial should work with the majority of Windows Mobile devices. It is paramount to make sure you get everything working via connect cable before you even touch bluetooth. I have had many problems trying to sync with bluetooth initially. Also, make sure all of your bluetooth partnerships are removed before proceeding. Let's begin:
1. Connect your phone to your computer. Vista will recognize it and install it.
2. Install Windows Mobile Device Center. This takes a bit. Vista will install driver information, and then proceed with the Windows Mobile Device Center installation.
3. Click setup device.
4. Remove existing partnerships with your phone to the device and follow the walkthrough. It will then perform an initial syncronization.
5. Once everything is syncronizing happily, it is time for bluetooth. Make sure your drivers are up to date. For you T60p users, click here for the system updater. Also, make sure your bluetooth is on, and both devices are discoverable.
6. Click on Bluetook Devices in the Control Panel and wait for it to find your device. Click on your device and start the wizard. Make sure you connect your computer to your device, and not vice-versa.
Have Fun.
With the quarter finally over, I am concentrating on some of the things I have been trying to accomplish personally. As with most things, I don't have much time. What is likely to show up in the future? My personal website is in the process of development to which I hope to complete within the next two or three days. This site will not necessarily replace this blog, but will provide a location to release the projects I intend on releasing. Of course, more posting is required. I haven't put forth enough effort as of late to this blog, and I apologize to my readers. We will see how things go.
JavaServer Faces are another way to take advantage of the MVC model for development. They are an important resource for reusing the view within an MVC design. This article describes an overview to the JavaServer Faces technology as well as how it works, and how it compares with similar technologies.
With software becoming increasingly the driving force in business everyday, enterprise development continues to evolve creating more extensive ways to manage information. With requirements of reusability and maintainability, it is no wonder component based methodologies present themselves. J2EE has done a phenomenal job in creating architecture and API’s for component-based development; JavaServer Faces are no exception.
JavaServer Faces simplify the creation of reusable user interface components in Java web applications. In short, JavaServer Faces encapsulate the complex portions of the view in MVC design. Originally, a client would send an HTML request to a J2EE web application. The implemented container would manage the request and send it off to a servlet controller. The servlet would then use Java Beans as the model, process information, and redirect the information to an appropriate view (JSP and HTML).
Herein lies a particular difficulty. Servlets are reusable components. If a servlet is implemented doing a particular task well, this servlet can be ported to multiple web applications with very little difficulty. This is the nature of component based development saving money and most importantly, time. Views by definition are proprietary to a particular web application. A personal website’s JSPs aren’t implemented on multiple web applications, because they have personal website information on them. JavaServer Faces eradicate this problem while providing even more pre-built functionality to the view portion of the MVC architecture. With JavaServer Faces, portions of a view on personal and business websites can be reused in numerous differing web applications. Moreover, they don’t even require the use of an HTML browser to display, and can be implemented to be rendered many different ways including WML. With this information in mind, how does it work?
Just like standard J2EE web applications, JavaServer Faces are powered by XML. Unlike standard J2EE web applications, this is not the application descriptor. JavaServer Faces implement another XML document alongside the application descriptor called the JSF configuration file. This configuration file declares the JavaServer Faces specific components such as: managed beans, validators, converters, navigation rules, and so forth. Although the syntax is beyond the scope of this application, this configuration file makes organization of the project incredibly easy as well as solidifies the loose coupling.
Besides linking XML, JavaServer Faces consist of two primary components. These components are JSF API and the tag libraries wiring JSF components to user interfaces. The JSF API is comprised of a series of specifications relating to: interface components, managed beans, validation, conversion, events, navigation, and rendering. The tag libraries contain the specification for integration of created components within a JSP page.
JSF user interface components represent component information and behavior. This component might be a button for example. This button would have attributes relating to the text displayed on the button, and when the button is clicked, it would fire an event. Of course, there is a framework provided to create custom user interface components. Another great features is the display for a particular component is independent of the component and a renderer is used to generate the display independent of a particular component.
Managed beans are java beans typically implemented to handle input and actions. EL can be used to bind a user interface component to a particular bean action or information. If the button example is used, the actionListener attribute of a button is set to a managed bean using EL. When the button is clicked, the method in the managed bean is fired. This method invocation is similar to swing and covers a lot of the event driven portion of JavaServer Faces. The user information is processed by the server, but what about validation?
Since validation is a must in any web application, integrated and custom validation is already provided in the framework. Simple validation rules can be applied to user input controls for things pertaining to lengths and ranges. The Common Validation API is also applied to almost all of the controls within JavaServer Faces. Since the validator framework is pluggable, it is easy to implement validation with any custom control as well. Now Java must handle the view redirection after the data is verified.
Navigation is one of the most interesting and powerful pieces of this package. Normally, the problem of navigation is generally solved through HTML links and server side redirection. Although this is sufficient, it creates a tight coupling between servlets, controls, and the display views. The navigation system within JavaServer Faces is managed through the JavaServer Faces configuration file. For any individual request pages, there can be a number of possible responses. These can all be managed with arbitrary labels which redirect to specified pages. For example: If I am specifying an authentication page, there can be a number of responses like success or failure or invalid username. These responses can all be individually mapped to independent pages. This gives an incredible amount of loose coupling keeping the component away from the individual implementation pages.
The other primary component of JavaServer Faces is the tag libraries. J2EE provides two different libraries. The JavaServer Faces core tag library and the JavaServer Faces HTML tag library. The core tag library accommodates the implementation of user interface elements in a form. This is validation, conversion, and event listeners. The HTML tag libraries house components for HTML aware browsers. These include input and output tags, command tags, and selection tags.
Although the setup of JavaServer Faces is similar to other technologies, JavaServer Faces have fundamental differences with similar implementations. Microsoft’s ASP.NET has a component based control implementation where the display code fires events to a code-behind file. The difference between Microsoft’s ASP.NET implementation and the JavaServer Faces implementation is the coupling. Since a code-behind is usually treated as one entity with the display, the ASP.NET implementation is simpler to use, but more tightly coupled with the view. JavaServer Faces are obviously useful, but what does it take to implement them?
To implement JavaServer Faces, one must first start with a JavaServer Faces compliant container. Once this is installed and configured, the only other pre-requisite is the latest Java Development Kit. Since this article is a primer to the technology and not a tutorial on creating JavaServer Faces, the actual code is beyond the scope of this article.
Although this article only scratches the surface of this incredible technology, it is easy to see JavaServer Faces are a phenomenal way to reuse MVC view code. They are pre-packaged with powerful tools, and are another way for developers to save time and effort within their development shops. For more information on implementing this technology, consult the sun website as they have an immense archive of tutorials.
Bibliography
JavaServer Faces Technology. The J2EE 1.4 Tutorial. Retrieved June 10, 2007 from
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSFIntro.html
JavaServer Faces. Wikipedia.com. Retrieved June 10, 2007 from
http://en.wikipedia.org/wiki/JavaServer_Faces
Manganellore, Rakesh (2007) Introduction to JavaServer Faces. JavaBeat. Retrieved June 10, 2007 from
http://jsf.javabeat.net/articles/2007/05/java-server-faces-introduction/
If a waiter stopped by right now to take your order, what cocktail or drink are you having?
Apple Martini
Computer users have adapted to the idiocies of early solutions. Back when software was developed solely for advanced users, programmers were in charge of defining the user interfaces of these pieces of software. The problem currently lies in the fact that this has not changed. This particular rant could go on forever so I am going to stick with the problems with the current saving solution.
Lets take a trip down memory lane to the last time you worked on a document. Whenever you made a change to this document, what did you have to do? Save. If you wanted to rename the document, what would you have to do? Save As. When you would like to save a copy of the document somewhere else, what would you have to do? Save As. The list can continue, but I shall make my point.
This scenario makes me laugh. I realize that the only reason I know this is because It has been ingrained into my head since the beginning of computer time. Is the save, save as method intuitive? I say "I know how to do it so it must be." Is it really though? Let's compare these current solutions to reality. In the computer world, there are usually 2 copies of a document. One in memory, and one on the hard disk. When you add the bibliography to that annoying assignment you didn't know required a bibliography, you are changing it in memory. Then, to put it on the hard disk, you save it. Back in the stone age, my buddy is writing the same paper by hand. But for some reason he doesn't have 2 copies, and when he writes something down it stays on the paper! Genius!
This article is called problems with software not solutions to software problems so unfortunately I am not posting a concrete solution to base the next project on. However, this doesn't mean I can't throw some ideas out there. The kibosh could be placed on the save and save as features. When one would like to back up their document somewhere, perhaps the backup button? When someone would like to file there document initially, perhaps the file button? When someone would like to rename this document to something else, perhaps the rename button will suffice. This of course requires the use of a nice undo system which allows you to undo file write-overs and things of that nature, but this is for later articles.
Remember, just because it is the standard, doesn't mean it is a good solution.
Note: This article assumes you have done some Java web development in the past, and you are capable of compiling and executing web applications with J2EE.
Overview
J2EE has done some amazing things in progressing the creation of custom tags. Now it is fairly easy to integrate any custom HTML tag within your application further separating the view from designers. This article will show you how to implement a custom HTML tag that calculates the square of a number by simply placing <math:square num="12" /> into your web application. Hopefully, you can feel the power with this simple feature.
Creating the class
Every custom tag extends SimpleTagSupport. This is a class implemented by the J2EE spec which allows a class to output information to a jsp. So, lets get right to coding. Create a class in your web application that extends javax.servlet.jsp.tagext.SimpleTagSupport. If you are compiling by hand, the class file must go in the package structure under /WEB-INF/classes/ i.e. /WEB-INF/classes/com/cyberkruz/test/NewMath.class
l
Every attribute in your custom tag must have a Java Bean mutator property to go with it. This is handled with reflection to send the parameter to your class.package com.cyberkruz.test;
import java.io.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.SimpleTagSupport;
public class NewMath extends SimpleTagSupport {
private Integer num;
/**
* Method overridden which is called
* by the jsp.
*/
public void doTag() throws JspException, IOException {
// Gets the jsp context and prints the
// number squared.
this.getJspContext().getOut().print(this.num * this.num);
}
/**
* Sets a number that our custom
* tag squares.
* @param num The number to which
* we want to square.
*/
public void setNum(Integer num) {
this.num = num;
}
}
Configuring the application to use the class
Now, all we have to do is let our application know that the new tag is there. To do so, we can set up a TLD file which looks much like the document descriptor for configuring servlets. So lets do it! Create a new file called MyTags.tld and place it in the /WEB-INF directory. Then type the following:
<?xml version="1.0" encoding="iso-8859-1" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3c.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<tlib-version>1.2</tlib-version>
<uri>myTags</uri>
<tag>
<description>Custom tags</description>
<name>Square</name>
<tag-class>com.cyberkruz.test.NewMath</tag-class>
<body-content>scriptless</body-content>
<attribute>
<name>num</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
This file configures our web application to use our new custom tag. Multiple tags can be placed and mapped with this single file. The taglib directive just specifies the schemas for this particular file and version. The uri specifies what location these tags are being mapped to. Under the tag element, the description and name should be pretty straight forward. The tag-class element points this tag to the class that we wrote previously. the body-content is stating that we don't want inline scripting for this element. Now the attribute tag is fairly interesting. While optional, it maps the num variable to our setter in the class we specified. Then, it says we must have it there (required element) and it can be specified at run time (rtexprvalue).
Now all we have to do is use it!
Place our new tag in a jsp
Allowing our jsp to use the custom tag is the easiest part. It only requires a single declaration.
<%@ taglib prefix="math" uri="myTags" %>
The taglib keyword tells the jsp what we are trying to do. The prefix is what we want to put before the tags when we call them, and the uri points to the uri specified in the tld file. This is going to load every tag that is configured in that tld file that we made previously.
Now, let's put it in a jsp. Create a jsp file called SimpleTest.jsp and place it in your web application. Place the following in your jsp:
<%@page language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib="" prefix="math" uri="myTags" %>
<html>
<head>
<title>SimpleTest</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
10 squared is: <math:Square num="10" />.
</body>
</html>
Run it on your web server and... YAY! This is a base introduction to what you can do with custom simple tags. More information about how to use these is below. Enjoy!
More information
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPTags7.html