|
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.
Using Perl To Convert Hyperlinks And Filenames To Lowercase
Like a lot of web developers, I'm not always that disciplined when it comes to the file naming convention I use and I sometimes end up with a situation whereby I have some files that are in lowercase, some that begin with a capital, and some that are a bit of a mixture. One web site I maintain contains about 2000 web pages and has about 20,000 hyperlinks. As you can imagine, I had one of those sinking feelings when I was told that in order to migrate the web site to a new content management system, all the file names and hyperlinks would need to be changed to lowercase. Whenever I am presented with a problem like this, my instinct is always to write a Perl script using one or more regular expressions to solve the problem. This particular situation was no exception. Change a string to lowercase The following regular expression changes all the characters in a string to lowercase. The first part of the regular expression finds a hyperlink, and the second part converts the string. (Just in case this article is not displayed correctly, there should be a single backslash in front of the 'L$1'). Change a filename to lowercase Likewise, changing a filename itself is very simple. The following two lines perform the task quite nicely: (Again, there should be a single backslash in front of the 'L$name'.) If you need more information on how to incorporate the above code snippets into a complete script, feel free to contact me directly.
How to Contract a Web Developer - Part I
The initial client-developer discussion is an integral part of the Web design process. This article will take a look at both the client side of the development procedure, as well as the best practice methods for Web developers to employ when speaking to their potential business partners. Your business is ready for a Web site... • Sell products over a greater range than you currently do All of these reasons can really be lumped into the super-category titled Increasing Business - the prime goal of any worthwhile advertising campaign. Generating authentic business and receiving solid leads is virtually money in your pocket; and in this day and age, the internet is the best domain for advertising your products and services. People turn to the internet to look for information like no other. In fact, it seems as though the internet is even replacing God in today's search for answers. Do some research on a few of the longer queried Google keyword-phrases. Chances are you'll come across some gems like What do I do if my boyfriend is cheating on me? Or how do I get my children to enjoy Vegetable X? For driving traffic to your soon-to-be Web site, you need to give users the potential to stumble upon your domain with their search engine queries. After all, what good is your Web site if nobody can find it? Forget everything you know about Web development. First thing's first: After you browse the internet for local developers or even check the regional phone directories; you must get to know your developer. And when I say get-to-know them; I mean get to know the quality of their work. At this point in the game you shouldn't even have made a phone call or sent an email inquiry. It is imperative that you take a close look at their Web sites and portfolio (if available). If what you see is visually appealing, consider it an added bonus, because, chances are, you're looking in the wrong places to measure their worth. Key point: Know what you're looking for. The face of the site is actually not that important. Don't be influenced by sites constructed solely upon Flash, or sites using a little too much dynamic Javascript. This after all, can only hurt you in trying to get your Web site indexed by the major search engines. Your best bet is to right click on the page and check out their source code. And when you're done with that, if you're using FireFox (which you should be using), go to View on the top toolbar and choose to view the page without style. This is a close representation of what search engines are seeing. Try running a spider simulator on the page to really see through the search-bots' eyes. When viewing the source code, if you don't see a DocType Declaration in the first line, let that be your only red flag and move onto the next developer. Another item of interest for you is standards compliancy. To check for this, run the page through the W3C's Page Validator Tool. While search engines don't necessarily see valid XHTML as a requirement, the closer the page comes to standards compliancy, the easier it will be read by search engines. It's a correlation-not-causation type of relationship. Also worth noting is that if Web pages are produced by a company, check and see who your developer is and their relationship to the pages that you were viewing. For example, if you like Page X in their portfolio and it was developed by Designer Y, don't settle on having Designer Z do it in the same way unless they work on the same team or were trained in the same vein. One more thing to scan for is a comment which may or may not exactly be . Remember, you're paying a good chunk of money for a custom page, don't settle for a recycled template. You want a unique design for your unique service proposition. If you specifically want your designer to use a template, make sure they design using the same conventions that appear throughout the template. Next up: Say no to Flash, nested tables, and all dynamic content other than CSS and basic Javascript. Checking for nested tables in design is really just keeping an eye out for a few too many tags that start with < tr >, < td >, etc. If they start nesting within each other in a recursive cycle - steer clear. This is an old convention for design that mimics the printed page, yet it is still a popular development practice. While developers still get away with such design, mainly because it has the capability to construct beautifully looking pages, sites built with these conventions will ultimately fail and break down as browsers and search engines move toward a more standards compliant approach. So, unless you are displaying tabular data, don't use tables or ask for them in your Web design. Whatever tables can accomplish can also be done with CSS. Enter Cascading Style Sheets Now that you know the criteria for choosing a Web developer based upon principles of design; let's move onto extended and comprehensive service. While it's not a traditional component of a single Web designer; maybe you'd like to hire a developer or development team that offers a complete Web hosting package including domain registration and email setup. While they're at it; wouldn't you like a few guaranteed site modifications and some technical support, to boot. Be wary of designers who design-and-drop. What happens when the next version of IE comes out (certainly guaranteed to break more than a few Web sites)? Or when you no longer offer Product X or you change your address, phone or fax. Do you really want to hire a new developer or draft one of your administrative assistants to decipher somebody else's code? In so far we have taken a look at what to look for when contracting a Web developer. Say no to nested tables, Flash and messy markup. Say yes to standards compliant CSS and XHTML. In the next installment of this article we will further discuss the interlocution between contractor and client in Search Engine Optimized Corporate Web Development.
|
* 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). |