|
just another regularban.info web blog |
| MEMBERS: | Passing Parameters In A Data Table Using JSF
Some working knowledge of J2EE or JSF is assumed for this article. Like some of you I've been frustrated with this technology known as JSF or Java Server Faces. There are several different flavors out there that are built on the shoulders of JSF. For instance Oracle's ADF (Application Development Framework). Oracle ADF Faces Components is a set of over a 100 JSF components that let you build a richer user interface for your Java EE applications. Oracle ADF Faces also includes many of the framework features most needed by JSF developers today. That is great, and in many ways it will make life easier to develop in a JSF environment. Some items you will find available in these "add on" packages have a real benefit. For instance, as of the date of this article, I was very surprised that a File Upload is a feature still not implemented in JSF in respect to using natural jsf tags. There are ways to accomplish this task in JSF but they are not native JSF approaches. The process is a "no brainer" in just about every other framework available today, including asp.net. Another simple task (I thought) was having a data table present the results of a query in an editable format. Possibly to update a user record or shopping cart. After working in other technologies it was very efficient to return a result set to a data table object and let that object take care of some of the trivial behaviors and characteristics of the table itself. When I started exploring JSF I was frequently and at every turn becoming more and more frustrated in trying to duplicate some of the most basic of processes similar to managing records through data tables. There are not a whole lot of resources out there yet on JSF although it is growing steadily, and I found that all too often the resources that I was finding on the internet either didn't apply to the more simple tasks or the information was just completely wrong. One example of that was that it was stated in one article I read that you cannot use command buttons inside of a JSF data table. The recommendation was to use JSF hyperlinks instead when trying to perform an action from a data table due to a bug in the framework that prevented command button actions to fire if the button resided inside of a data table. At first I thought "you've got to be kidding me"! Then I remembered that I've been finding a fair amount of "bogus" information in regards to JSF development so I decided to do further research and discovered that information to be less than accurate as well. I simply had to find a way to populate a data table through a result set and get a command button to fire an action and pass all of the data in the data table to the backing bean to update the record. Multiple command buttons would exist as well as hidden fields pertaining to id numbers and so forth. Pretty basic stuff and we've all done it before with relative ease. It turned out that the solution was in fact a simple one. "Binding". You've heard about it and read about it. But this approach was something a little different as far as I could find. Many of the blogs and articles that I read dealt with passing the values as parameters and following the steps to define the parameters in faces.config files etc., then retrieving the parameters in a backing bean. Processing the passed data required another set of procedures to utilize mapping to each of the field parameters passed and then processing could begin. That seemed like a whole heck of a lot to me just to retrieve form data. Then it occurred to me that I should be able to "bind" a text field component on a page to a backing bean. Once it is bound then all I have to do is extract the data. And that's all there is to it. My query returned results and pre-populated a data table including text fields with the values of the query pre-populated in the text fields. Each one of those text fields was bound to a "HtmlInputText" type in my backing bean. It was not a String type like other approaches define. Doing that does require you to map parameters and populate that String variable through your set methods once the form is submitted. What I found is that if I bind my text field to a property of text field type that it solved my problem of passing values from a data table, and I didn't have to define parameter fields anywhere in any xml file. Now that I had that figured that out I needed to figure out how to get the value of that property that I've bound my form field to, well why not getValue()? I personally hadn't seen any examples online or in books for retrieving the value from a form binding it to the type of form element it was and simply use the getValue() to pull out the value of the object. Used like this getParameterFromForm().getValue(). Let me clarify that I am NOT saying that trying this approach isn't documented anywhere, I find it hard to believe that I've had some stroke of genius that no one has had before in the world of java, especially since I'm coming from .NET and ColdFusion. After doing that I no longer had any problems passing form data to my backing bean. I was able to dynamically populate data tables with any number of records including any number of command buttons within that data table and I didn't have to concern myself with remembering to define parameters in any other areas of the application. So put simply you can bind your form fields to properties of the same type in your backing bean, and then extract the value of that object using getValue() if you prefer over utilizing parameter string mapping and similar approaches for processing form data. I found it to be easier and less time consuming which has costs associated to it as well.
Website Navigation
Importance of a navigation scheme One of the most important tasks when developing your website is creating a navigation system that is effective and easy to use. People have a tendency to try to include everything in the navigation tree all at once. Instead they should follow the same process as setting up the structure for the site and break it down in levels. This would be information relevant to the homepage that directs visitors to the main sections of the site. From the main sections of the site, the user gains access to the sub sections containing content pertinent to that section only. Remember to always include links back to the main sections and your homepage on every page in your site. While you are creating your navigation setup, try to look through your user's eyes. Remember, you are the one creating the structure, so you are biased in your opinions. If you think about what someone else might say or do, then you are one step ahead of the game. As you create you website navigation, make sure that links can be added in the future with no difficulty. You must always keep in mind that your site must be flexible and open to change because it is never completed. All links should be clear and to the point. It makes no sense to have your visitor try to figure out where they are going. They should be able to quickly look for what they want and then access it in a timely and efficient method. There is a better chance of a visitor going somewhere else if it takes too long for them to find the information they are looking for. Your navigation scheme should stick out and be located in a common spot on every page of your site. Consistency allows your visitors to focus on the content instead of trying to figure another navigation system for the same site. Linear navigation Linear navigation provides the same capabilities as your forward and back button on your browser. With this navigation style, you cannot jump around and skip pages. Reading a book or viewing a PowerPoint presentations are also examples of linear navigation. As you read through the pages, it makes no sense to jump around or you might miss an important piece of information. People who create sites with this style often are directing the visitor from a starting point to a predetermined end in a step by step fashion. Your links will not allow the user to anywhere other than where you want. Hierarchical navigation Hierarchical navigation allows the visitor to go from a homepage to the main sections of your site and then to the subsections. Visitors can travel through your site without any restrictions. This type of navigation ties all the areas of your site together so any page can be accessed from another in as few clicks as possible. Hierarchical navigation is best used on sites that are filled with information and to be utilized like a library. Sitemaps for navigating through your website Sitemaps provide a list of organized links to the content of your website. The same way a table of contents tells you what is inside a book, a sitemap does the same for your website. Your visitors are given a one page view of the information structure that your site is based on. Sitemaps are not meant to be your websites primary navigation but more as a compliment to it. Navigation bars A navigation bar gives your visitors the ability to move between the different sections of your website. It should be placed on every page of your site and should be consistent as well. Placement of the navigation bar is entirely up to you. The navigation bar can go on the left side of your page because most people read from left to right. It can also be placed on the top of your page so it is the first thing your visitors see. Some people place it on the right hand side of the page intentionally making a visitor browse through content to then be able to navigate the rest of the site. Theme and navigation links The theme for a website is created with the way you use color, fonts and images. During the theme creation process, remember to not clutter your pages with unnecessary content that will draw your visitor's attention from the main content. There are many ways to create a theme. One example might be a newspaper look consisting of black and white colors with a plain font. Themes give a website character and often leave a strong visual impression on the visitor. Your website theme needs to be used on all your pages which helps tie your site together. Navigation Navigation of a website should be an easy process and not require the visitor to take much time in figuring out how to move through your site. Visitors have come to your site looking for information and should be able to find it easily. If a visitor has to waste time figuring out how to get what they want, they will go to another site. Navigation is not just for people, but search engines as well. Set up the navigation to allow search engines to follow the links to index your entire website. Your navigation scheme should appear in the same place on all pages. When a visitor navigates through your site, make sure they can flow through it. Do not set it up so a visitor has to use the back button of the browser to access another page. Through navigation, your visitor will have access to pages in your site, to other sites and to different sections of the pages on your site. You will need to place navigation menus in more than one area on your pages. There are many good ways to help the visitor move through your site. The most simple is a text link. The next is a navigation bar placed on the top or sides. Another is the use of graphic buttons created to help compliment the overall look of your site. It is always good idea is to include links at the bottom of your page in case someone does not feel like scrolling back to the top. Through navigation, your visitor should be able to get where they want quickly, know where they currently are on your site and be able to access other pages on your site for additional information.
How To Create A Powerful Website
So you're considering building a website and you may be feeling a little overwhelmed by it all. While this can easily happen it is wise to whip out some note paper and write down exactly what you want to achieve and what steps you need to take in order to get there. So the first thing you are going to need to do is put the foundation in place. This will require extensive research. Now contrary to popular opinion I start this process a little bit differently than what is generally advised. Now while we all know that you need to find a hungry market doing this can be a little more difficult than explained in actual fact that is just like everything else when it comes to doing anything online. Actuality can be quite different from theory. So what I do is visit the article directories. I punch in a keyword that I am interested in and see what articles come up relative to that. Then I check the articles out to see how many page views they have received over a given period of time. If an article receives a lot of page views then I know that there are a number of people looking for information relative to this subject. I also know that if I write an article on this topic that it will receive a lot of page views and as a result get a lot of click throughs to my site which will help me get traffic quickly without having to worry about what Google and everyone else does. Next I visit the forums to see what solutions are being discussed then I go back to the articles and check what the writers are promoting and see if it is a valid good product to help people achieve the goals they desire. If so then I make note of it. Now I feel a little more confident about building a site around this theme. The next thing you have to consider is the domain. A keyword in the domain is helpful but not essential. Your next quest is hosting. You need a good host as this is your life line. Finally you want to be able to build the site effectively so as to achieve good search engine rankings. Keyword research relative to your overall theme will help you to do this plus you need to structure the pages properly so that you site can be understood by the search engines. Do not worry if you lack technical knowledge as there are site builders out there to help you overcome this challenge. Select any of the following links to watch some free videos.
|
* About Archives
Categories:
Last Updated: |
| regularban.info
is proudly powered by WordPress MU running
on regularban.info.
Create a new blog and join in the fun! Entries (RSS) and Comments (RSS). |