Saturday, December 25, 2010

I am currently in the best seat in an IMAX 3-D version of Tron Legacy!!!! Been waiting most of my adult life for this sequel. Lol...

Friday, December 17, 2010

JSF 2.0 paper coming

I am on the hook to present JSF 2.0 New Features presentation to the NoVAJUG February 17 or so. It should be fun. JSF 2.0 is really cool. I will publish this presentation to slideshare when I get it fleshed out.

J-Integra

On the project I am at now we are using a product called J-Integra for COM. It allows us to control Excel (in our case...probably any MS Office tool) through DCOM in Java. We tried things like Apache POI and Actuate BIRT Spreadsheet Engine/API first, but the spreadsheet we had to control had visual basic macros in it which called C++ DLL's. And Java does not (yet) understand anything about VBA, so those efforts did not work for us.

The set up of J-Integra is fairly minimal. There is a license xml file which is emailed to you upon request, and you must rebuild their product's JAR files using their JAR rebuild command. Then you have 30 days.

At that time you can run something called comtojava (I think) and it generates a great many java/class files which do the DCOM calls. There are also a lot of interfaces in there defined.

The result is that you can open/create a workbook, manipulate it, and close the book. The opening actually opens a copy of Excel, so you have pretty much complete API access. It is almost like a testing tool.

Hope this helps.

Friday, October 29, 2010

kudos to JSF 2.0's f:ajax tag!

It has been verging on too long since my last blog entry.

I have been reading in JSF 2.0: the complete referece by Burns, Schalk and Griffin about the f:ajax tag, and the Ajax implementation in JSF 2.0.

It's really cool.

Here is my background with Ajax. I have implemented Ajax solutions in JSF apps using straight JavaScript. This was kinda hard but not too bad actually. But I am fairly comfortable with JavaScript. I have also worked with the JSF Blueprint auto-suggest component. This worked out rather well and hid much of the details of the JavaScript functionality behind a JSF component. I have also studied a bit more than half of Deepak Vohra's book Ajax in Oracle JDeveloper and seen what a huge number of ways there are to do Ajax...and that is just with Java! I have also been working with ADF 10g's PPR solutions and my own frame/iframe kluges for years as well.

I really like the simplicity of the f:ajax tag. For starters, I love that you can get some basic, useful Ajaxian functionality simply by including the f:ajax tag either inside or wrapped around you JSF tags! This basically would do the equivalent of submitting those fields when the default event for those JSF components fires. The default JavaScript client event for a component is a sensible value depending on whether it is an action component or a value-change component.

Then it is possible to have all the flexibility of doing Ajax from raw JavaScript.

It is certainly much much easier than having to construct a bunch of JavaScript then do a bunch of request hijacking from a PhaseListener, like in JSF 1.1 and 1.2.

Thumbs way up guys!

Wednesday, August 18, 2010

Value Change listener method hint

Here is an important fact. Amazing even.

If you have ever experienced where you have a difference in the behavior of your ADF Faces screen between when somebody when you do a commit by executing the commit Action binding, or doing a commit by pressing a commandLink which fires an action binding...I have some help for you.

In my (sample) senario, I had changed a name in the Name field on a screen. I wanted to get this change into the database, because there is a unique key constraint in the database on the table column associated with this name field. When I create a new record, I call a pl/sql procedure to do the work, then execute a query, then go to the screen where this name field is. The name field has a default value in it, but it is important that the end user change this name field. So I put a value change listener on the name field, so that if they change the name, a commit will be fired.

The only problem was that the value change listener method is called before the value in the fields gets written to the binding layer. So you have to force it prior to calling the commit.

If you have Steve Muench's EL helper class you can do the following in the value change listener method:

EL.set("#{bindings.Name.inputValue}", valueChangeEvent.getNewValue());
Works great!

Thursday, August 5, 2010

AjaxTags

As I continue to work through Deepak Vohra's Ajax in Oracle JDeveloper book, I was very impressed not only by the book (thanks Mr. Vohra!), but also AjaxTags.  I must be tag/jsp-oriented, because I tend to view just using javascript to do Ajax as being kind of messy.

It has not taken me very long to get the example in this book which demonstrates AjaxTags up and running.  There were a few gotchas.  For example, in the example there were only three javascript files which needed to be included in the jsp page using script tags with source attributes.  The book was written in 2006.  Now in 2010, using the next major version of AjaxTags there are 7 or 8 javascript files, which I had to include.   Also Vorha-ji used a "button" tag, which in my browser issued a submit.  If you are doing Ajax you don't want to use a button that automatically submits, so I switched to using an <input> tag with a type attribute with the value of "button".

With this example I could register a select list and a button to do Ajax transactions with (in the jsp) only the following two tags:

<ajax:htmlContent baseUrl="formservlet" source="catalogId" target="validationMessage"
parameters="catalogId={catalogId}"/>

<ajax:updateField action="updateForm" baseUrl="formupdateservlet"
parameters="catalogId={catalogId}" source="catalogId"
target="journal,publisher,edition,title,author"
parser="new ResponseXmlParser()"/>
So, in this example, you had to define two servlets, one called formservlet and one called formupdateservlet.  The ajax:htmlContent tag above made it so that if you changed the selected value of a select list with the id of catalogId, it would "doGet" on formservlet with the request parameter which has that selected value.  The value of the element with the id of "validationMessage" (as specified in the ajax:htmlContent tag above) is set to the text of the response of this servlet.  That is a lot of meaning to pack into a little tag...but that "meaning" is just what we want, time and time again...isn't it...with AJAX.

The second tag, ajax:updateField, keys off of a button whose id is updateForm (see the action attribute of the tag above).  This button click does a doGet on formupdateservlet, again passing the parameter of the current value of a select list with the id of catalogId.  The target attribute is a comma-delimited list of element ids in our form of various fields we have.  This servlet (formupdateservlet) produces XML, unlike the formservlet, which just produced text.  So we specify a parser in the tag above to handle the XML.  I think then that you just have to make your servlet produce elements which match these target element ids.  Again...very compact...but exactly what we are looking for.  The only javascript involved is the script tags which include the AjaxTags javascript libraries.  These are the ones I had to include:

<script src="prototype.js" type="text/javascript"></script>

<script src="scriptaculous.js" type="text/javascript"></script>
<script src="overlibmws.js" type="text/javascript"></script>
<script src="effects.js" type="text/javascript"></script>
<script src="controls.js" type="text/javascript"></script>
<script src="ajaxtags_controls.js" type="text/javascript"></script>
<script src="ajaxtags_parser.js" type="text/javascript"></script>
<script src="ajaxtags.js" type="text/javascript"></script>
Scriptaculous is used to make some of this happen, and is part of AjaxTags.  It has some support javascript files which I did not include.  It would probably be safest just to include all of them, since there are not that many.

That's it! 

I would like to explore this a bit more (since this example does not begin to cover AjaxTags functionality fully) and see how it performs when incorporated into JSF pages.

Wednesday, August 4, 2010

Continuing to look at Task Flows

I have a question now about Task Flows in Oracle ADF Faces/Bindings 11g.  I see from reading Frank Nimphius and Lynn Munnsinger's new ADF book, how you can make two page fragments talk to each other by creating an event map in the parent page's pageDef, and then raising events in one fragment's bindings, and "consuming" these events with a backing bean method in the other fragment.


What still does not make sense to me is...how does the binding know what event to raise?  Granted:  I am still messing with ADF Faces 10g, but af:tables, af:tree's, etc. have more than one event associated with them.  And yet in this book I do not remember reading a description of how and event raised in the binding knows what kind of event to raise...


For example if I select a node on a tree and that triggers a context event, and then I expand a node on a tree and that triggers a context event (if that is possible...?), where does the link occur between the binding event and the particular component event?


This has more to do with events and production/consumption of them across bounded task flows for page fragments. The example in the book is as follows. On a page there is a panel splitter. On the left side is a tree with deparment nodes and employee nodes under each department node. On the right side is either a department or an employee data update screen with fields and a save buttons. The selection of a dept or emp node on the left gives you an update screen on the right with the correct row queried up. The left and right side are both regions with bounded task flows inside containing page fragments. the parent page (the one with the splitter) has the task flow bindings on it, plus it has the event map defined on the task flow bindings.

So the part I am confused about currently is when you click the tree and the tree binding raises an event, you just enter in the page def for the tree the xml element <events> with and <event> sub-element in it. In the event map you map this event producer to the consumer page/bindings on the right to get a sub-dynamic task flow to either show a emp or dept page fragment. But I do not see where it says what kind of event is getting generated. Surely a tree node can generate more than one kind of event. for example a node can be clicked/selected. Also a node can be disclosed/opened or closed/shut/collapsed/whatever.

I think the following comes close to answering my original question (taken from FUSION DEVELOPER'S GUIDE 11g):

You can raise a contextual event for an action binding, a method action binding, a value attribute binding, a tree binding, a table binding, or a list binding. For action and method action bindings, the event is raised when the action or method is executed. For a value attribute binding, the event is triggered by the binding container and raised after the attribute is set successfully. For a range binding (tree, table, list), the event is raised after the currency change has succeeded. Value attribute binding and range binding contextual events may also be triggered by navigational changes. 

Contextual events are not the same as events raised by UI components. For a description of these types of events, see the Oracle Fusion Middleware Web User Interface Developer's Guide for Oracle Application Development Framework. Contextual events can be used in association with UI events. In this case, an action listener that is invoked due to a UI event can, in turn, invoke a method action binding that then raises the event.

What is confusing to me is the documentation says you can associate an event with bindings of different types, and that the binding-associated events are not the same as ui component-associated events. But then they turn around and say that these binding-associated events all happen in response to actions for which there are component listener properties. So I naturally would assume that we would then says that...these binding-associated events are raised in direct response to the corresponding component event.

From a high level, anyway, it appears that for these binding-associated events we are triggered by a particular event in association with that binding. For range bindingg (tables, trees) the big event is changing of "row currency". (OR POSSIBLY NAVIGATION). Action/Method: when the thing is executed. Attribute -- when the value is set. So I guess the payLoad is different in each case? For the row currency, is the default payload the row? I think for the action, the payload is whatever the action or method returns...? the attribute...the new value? More reading...

Wednesday, July 21, 2010

Continuing Impressions of JSF 2.0 Cookbook


7/16/2010 9:36:01 PM


 

After just having gone through the selectOneMenu custom car converter example, I have to admit it does seem to use JSF to best advantage. I have often wondered why SelectItem takes an Object as its key value. I kept thinking: why isn't this just a String? This example answers that question. I learned that a converter is called for each item in the select list to come up with the options element values within the generated select list.


 

This must be one of those powerful examples that the author was speaking of in his forward. Nice! I am glad to have this example as a reference, and look forward to trying to these list concepts right from now on.


 

7/18/2010 7:41:48 PM

OK, the next example is just a tweak of the first example; the code as shown in the book, however, does not work. However it is very close to what does work. The value of the selectManyCheckbox should be a list of CarBeans. And the rendering page should have the dataTable having a value of the same list. In the managed bean I defined such a list and in initialized it to an empty ArrayList of CarBeans. After this adjustment this example worked fine. After looking at his example code this is what his example did; it would be good however if in his book, he were to mention changing the datatype of the selectedCar property.


 

The next example is fine and is explained fine, although the names of his variables were odd. Calling a number converter "number" and calling the number that was being converted "numbery" was bizarre. I guess the author had his reasons.


 

This next example is good. It is exposing some converters in other JSF component sets – RichFaces in this case. I am looking forward to trying it out and starting to get a feel for some JSF component offerings other than the ones I am currently familiar with.

Monday, July 5, 2010

First Impressions of new Book


Overall I think the cookbook is pretty good. I am not very far in it yet, but it seems like the author is a lively creative technically proficient person who will probably do a good job covering some intermediate/advanced JSF 2.0 implementation topics. I would say beginner also, but I think there is too much left out to really call this a manual that helps beginners.

If you would like to see my first impressions as I had them please keep reading…

6/25/2010 6:35:24 PM

Sounds like Anghel Leonard (author) has some good experience writing books and developing Java and maybe other technologies.

When reading a technical manual I always study the table of contents. After doing so I am usually more excited about what I am reading because I am aware, not only aware of what the book covers, but also of topics and combinations of things that I have never thought of before. That is certainly the case with Mr. Leonard's book's Table of Contents. I come away from his TOC thinking that if I can learn about 1/7th of what is in this book I will be learning quite a bit! He covers not only JSF 2.0, but apparently how it integrates with 30 or 40 other technologies. So: I am looking forward to continuing to read. On to the Preface…

"What this book covers" is an elaboration on the TOC. After reading that and the following section, "What you need for this book," I am beginning to wonder if this is more of a JSF book with some JSF 2.0 thrown in…? Not sure there seems to be some indication that you can use this book with JSF 1.2 or 2.0. I am wondering how that would/will be accomplished? At any rate, even if the subject matter had little or nothing to do with JSF 2.0, the range of topics seems amazing…and I am still looking forward to continuing my read…although…if JSF 2.0 is not so much the focus, maybe the book should not be called JSF 2.0? OK, I will shut up and continue reading to see what Mr. Leonard's bent is.

The who is this book for section: I am not a newbie to JSF, but I would love a look at some "best JSF practices," so I can improve my coding ability and compare the code I have seen in projects that others have written, and code that I have written and see how it compares/sizes up.

I just noticed something kind of funny. In order to assure that copyright is maintained for the e-book copy they gave me, they have given me a pdf with a not at the bottom saying this book is registered to me, then it gives my address, but instead of <city>, <state> <zipcode> …they have put <city>, <county> <zipcode> …I guess I am easily amused. Just like when I first started trying to learn a bit about Hindi, I learned that /dood/ means "friend". I found this funny because "dude" in English is sort of slang for "guy", or about 15 other meanings…probably including "friend"…in fact some people communicate *only* using the word "dude" with different emphases and inflections. Aside over.

Well, I found my first typo on page 8; typos are probably the price you pay for getting relevant textbooks out before they are out of date… I can live with typos, as long as the example code works. I will download the errata, example code, netbeans, and other software needed for the exercises in this book (looks like about 25 different software packages!).

OK, now wait a minute. The author used a phrase "converter lifecycle." Strictly speaking it is the JSF Request Lifecycle he is referring to. And what is a "render page?" I know he knows what he is talking about, and I am probably picking at nits…so I will try to tone it down a notch.

I can tell that reading this manual will take some getting used to. I am not sure where the author is from, but I am having a bit of trouble negotiating his explanations. Right now, however, I am kind of tired; so perhaps this is an unfair statement. Maybe with more sleep and a little patience I will have a better "meeting of the minds" with Mr. Leonard.

I can tell he is covering the material. It kind of seems like he has 1000 different ideas in his mind in his head about a particular subject and the sentences he reveals come out like lottery balls. But let's face it: his goals for the audience of this book and the breadth of the topics he covers, this book may end up being more like trying to read War and Peace, by carefully tearing each page out of that book, stapling these pages to the Bonnyville Salt Flats in a straight line, fixing a camera pointing downward on the side of the Blue Flame car, and then trying to read this novel through the camera's eye view while the driver uses the line of pages as a guide-line to drive next to.

6/27/2010 7:49:26 PM


 

I think I am in a better frame of mind now. Sorry for the whining…anyone who might be reading this. I have downloaded the code and started filing errata on this text.


 

It is fairly embarrassing but I have never tried net beans. I downloaded version 6.9. Since I already had glassfish v3 installed. I saw from the startup script for my already-installed glassfish app server that the default domain name was domain1. So I was relieved when I gave Netbeans the install directory (c:\glassfish3 on my machine) and it found domain1 automatically and installed it. I just had to go to the window menu, services sub-menu, and specify I wanted to add a server by right-clicking the servers node and choosing "add server…".


 

Then I opened the Projects window, and right-clicked New Project…


 

I created a new Java EE project. It activated "Java Web". I took the defaults on this application. So it created an application with two Java EE modules: an EJB module, and a war module. These basically correspond to the model and viewController projects on a JDeveloper application. The war module had a libraries directory, to which I added the JSF 2.0 libraries. Then I created a new page under the war module's Web Pages folder. The page type I created was "JSF Page"; this allows you to create a facelets page. When I created a facelets page, netbeans automatically added a web.xml file.


 

Netbeans creates a default "hello world" facelets page. I was able to run it by right-clicking the .xhtml file I had created in the Projects Window, and choosing run file.


 

At that point I was able to simply put the code into the ide.


 

7/2/2010 6:26:56 PM


 

I like the simple example that Mr. Leonard starts off with. I wish that the text had not chosen to put a line break in the middle of the "faces-redirect" directive/parameter; the author used this feature but did not really explain why. The other JSF 2.0 book I read did not use this until they had explained why. Not sure which is the better approach. This directive does not work if there is a line break. I am assuming the sample code is OK in this regard so that one can check this. Probably though, since the line break does not throw an error, anyone that copies the text out of the book will never know that it was wrong, but perhaps they will see it and it will start their subconscious mind working on getting-used-to-seeing-it so that later, when it will probably be introduced in earnest, the learning will come easier.


 

But, as I said I do like the first example, because of its simplicity. This simplicity allowed me to find my feet with netbeans, to experiment with explicit conversion (explicitly using a double converter when the backing bean property is an int…just to see what it would do.


 

Aside: in case anyone is wondering why I am focusing so much on JSF 2.0 lately, I am thinking that Oracle will maybe keep using JSF and eventually adopt this standard…perhaps even soon. So, we will see; just trying to paddle ahead of the wave so I can surf to shore in style. End of aside.


 

I think the use of the term "recipe" in this book may not be the best word; while the code is enough for me, the beginning of the book says one sort of audience this book is supposed to cater to is people who know the basics of JSF and not much more. Such a user may not know anything about, say, setting up netbeans or glassfish and could be given a little more help possibly. Typically a recipe in a cookbook spells out precisely what you need to do to make it happen. Of course if you do not have a tablespoon, or know what a degree of temperature is, or what an oven or a stove is…well you have a problem. I will continue to reserve judgment.


 

The second example is a good example for f:convertNumber component; it shows lots of different usages for anybody needing them. At the moment I do not, but it is nice to know this resource exists for reference or to teach a beginner. Also I enjoyed seeing some usages of Max* attributes, as I have mostly used patterns when I needed them.


 

I really like the next example…especially the usage of locale. I have not used the locale features of JSF much, and it is nice to know there is that flexibility whenever we may need it.


 

The next recipe is a toughy. This seems like a tip/trick, of which it will take me a while to discover the true value. This recipe deals with JSF sometimes inconvenient habit of not being able to use a converter to deal with null values, because converters are not fired. This is an annoying feature of JSF. The nice thing about JSF 2.0 is that there have been some new additions to help alleviate this pain (NOTE TO SELF: GO RESEARCH WHAT THESE ARE AGAIN). But it is always good to have many ways to do something in case one particular method has side effects you do not like. So thank you very much, Mr. Leonard. I will have to read it through a few times and maybe implement the recipe before I completely get what it is doing.


 

This keeps occurring in this book. I can tell that Mr. Leonard is probably not a native English-speaker (just like I did not grow up speaking Romanian, which may be Mr. Leonard's nationality and native tongue). What keeps occurring is I keep getting distracted by certain usages of the English language. These usages may make sense in Romanian (assuming that is Mr. Leonard's native tongue), or they may be perfectly fine usages of this word in some dialect of English, or perhaps they sound like other English words and get swapped out for the correct word, or perhaps Mr. Leonard is just creative. At any rate, I am having trouble reading the text of this book quickly because of strange usages of interjections that are not used quite right (in my opinion), words that are close to some other word like "particularity", and words that are not helpful, like "Placebo.". In the case of particularity, I think he might have meant "peculiarity" or probably some other word. He seemed to want to say that the hash codes on null objects will be different than the hash codes of non-null objects when using this class. And the use of Placebo brings to mind the usage of a sugar pill instead of actual medicine. Maybe NullConverterObjectHelper would have been another choice that would have made more sense when read back.


 

Still though, I would have never thought of this approach; so: bravo, Mr. Leonard, for your creativity, and thanks for the tip and the insight into directly overcoming this problem.

7/5/2010 1:52:33 PM


 

I implemented his example, and now I see clearly what he was trying to accomplish: whereas before I thought he was trying to obtain a substitute for the required attribute for EditableValueHolder components, which would still run use the converter, I see in his example he is trying to also intercept an initial value as well of the managed bean property in question. I am not sure however why he decided to make hashcode Placebo return a value…why not just look for instanceof Placebo in the converter? I am also trying to decide in my own mind if Placebo was really the ideal name for this class. It's purpose is to substitute for a null value…but it serves a real purpose, unlike a real-life placebo…ah, who knows anyway…I know what he means.


 


 


 

Thursday, June 24, 2010

Reviewing JSF 2.0 cookbook

Well, readers, I am reviewing a book for Packt Publishing, called the JSF 2.0 Cookbook by Anghel Leonard.  My mind is open and I am expectant about the content, as it surely seems like good subject matter; I will be getting started reviewing it probably on the plane ride back to Denver tomorrow.

Here is more information about the book:  book link  

I will let you know my impressions for this book and the two other big ones I am working on as well, as usual.