Wednesday, October 04, 2006

Ignorance and Java Server Faces

I'm not quite sure why it's called Java Server Faces - perhaps beacuse it makes my server a two-faced liar - but they're here. Specifically, we're using JSF with Tomcat and Apache MyFaces and whatever versions of the JSF API that Maven decided to pull down today (I think we're on 1.1).

Now, I don't have the time to read a few books on the subject, so I'm feeling a bit ignorant and inadequate. That feeling, however, is amplified many-fold by the fact that I am unable to step through most of the code that's not behaving the way I expected. Perhaps I could get there by downloading big tarballs and configuring source attachments in Eclipse, but I worry this may be a big black hole and I'm reluctant. The balance of JAR files being managed in my IDE and deployed in various cases is already quite precarious, so I don't want to upset it.

The second thing I miss desperately is pdb's (the python debugger) interactive prompt. Some things are definitely not working the way I expect. I can get some way with the Eclipse debugger and watch expressions, but it's cumbersome and slow.

Thirdly, my productivity is hampered by the constant re-compiles. Every time I change something, even a template, I'm recompiling and re-deploying to my local Tomcat instance. It's possible that I could find a way to edit templates in-place in the exploded .war file in Tomcat, or hot-replace them at least, but the only way I knew to do that was with MyEclipse and it doesn't like my Java Facelets templates.

This is not made better by the fact that we have three dependent projects. I have to a dance in Eclipse and Maven that involves 'mvn clean install' on a dependent project, cleaning code in Eclipse, and then re-deploying the project. I just lost nearly an hour pulling my hair out writing banal tests when it turned out that Tomcat wasn't executing the code that was being shown in my debugger. Meanwhile, this blog post has formed whilst I'm waiting for things to re-compile. Each time, my distraction period grows a bit longer, and my productivity dips a bit further.

Lastly (for now) there is way, way too much magic going on with JSF components. As far as I can tell, every form button is actually managed by a generated snippet of inline JavaScript. This (or something else) is managing some state that persists across Tomcat restarts, which sometimes is persisting the component tree (i.e. the tree of JSF components, which is formed by XML tags in various nanespaces, interleaved in non-obvious ways with the DOM of page itself). Sometimes, I get bizarre errors because some remnant of the page from half an hour ago is still being processed. Sometimes, not reliably reproduceable. The only way I've found to reliably test my code is to close down my browser completely and then re-open it after each re-compile/server re-start. Joy.

Further, sometimes the state appears to be saved but it's not - when I click a certain button which has a client-side handler (which is hooked up to a method on a bean by way of some magic expressions) but which aims to stay at the current page after processing, the UI shows form controls with values still entered, but they are magically lost when I click another form button causing an empty form to be submitted. Oh - and sometimes the first command link (think an <a> tag, except it's actually handled with some inline JavaScript on an onclick event and bound into the JSF dispatch machinery) that I click immediately after the application is started leads to a blank page being rendered (something about a phase of the component tree rendering not being ready, I read somewhere), and I have to re-load it to see anything.

I'm sure I'm just ignorant and that there are better ways of going about all of this, but I've spent as much time as I can afford with books and Google, and now I just need to get some work done. I'm patching together working practices that feel inferior and clumsy, but basically work. Luckily, this application is small, so there's not that much to do. But it doesn't feel particularly elegant. (/me wants a view and a few adapters)

Please refrain from pointing and laughing, but if you have some useful tips, I'm all ears.

11 comments:

Duncan McGreggor said...

Sadly, I have no experience to act as aide in your need. I do, however, feel your pain (as I am sure everyone in the python community does). Not only that, but I am feeling your frustration viscerally. I'm sure if I dwelled too long on those feelings, I'd want to throttle those responsible for forcing you to use such an inefficient framework.

Jean-Marc said...

There are ways to do the equivalent of "filesystem directory views" in order to develop JSF pages, as in Zope2 (without redeploying each time). It depends on the application server that you are using.

Facelets have a development mode too with a 2 second refresh rate.

for debugging, eclipse has an integrated debugger, with breakpoints, and everything you need...

as a general rule, if you need answers to these questions, I think that it is better to post on jboss or tomcat forums directly. For j2ee issues, you won't get much help from plone users, I suspect.

Martin Aspeli said...

Of course ... I'm venting. :)

I use the Eclipse debugger, with remote debugging against Tomcat, which helps quite a bit. I am aware that I can edit files directly in the Tomcat instance, but my project is compiled (by maven) and deployed to a Tomcat instance, so the source in Eclipse is not the same files as the ones in Tomcat. MyEclipse had some support for hot-deploy of JSP files but seems to struggle with facelets and with Maven managing the project in general.

Jean-Marc said...

Martin here are some pointers that can help:

http://raibledesigns.com/page/rd?entry=editing_java_webapps_instead_of

http://wiki.jboss.org/wiki/Wiki.jsp?page=ExternalDirectories

If you need to recompile classes, it is more complicated (as in zope), but for changing only JSF pages that shouldn't be a problem.

for facelets have you enabled the facelets.DEVELOPMENT parameter?

By the way, this is one reason why I'm writing cpsskins for JSF (now called "NXThemes" since yesterday) to avoid the pain of having to redeploy or modify XML files to change the layout of a site.

Best

Martin Aspeli said...

Thanks, Jean-Marc! :)

smallnew2000 said...

Cool pictures! Interesting blog!
Please test my sites:

free bible mp3 download
chrysler orange county
bmw 5 series
chrysler orange county
xanax addiction
penis health
eastman kodak
erotic file x
fuji accessory
patient advocate
opel sintra
energizer rechargeable

Jaffe said...

Hey, while searching for widgets for my blog, I stumbled upon www.widgetmate.com and wow! I found what I wanted. A cool news widget. My blog is now showing latest news with title, description and images. Took just few minutes to add. Awesome!

gfutfy said...

In English class, one girl Cheap WoW Gold said never buy WoW Gold give up when discussing. It just reminded me wow goldsomething about myself.WoW Gold Maybe it is wow power leveling something about love.WoW Gold My love, which began on July 3rd of WoW Gold 2005 and finished on August wow leveling 23rd of 2008, taught me many things. wow leveling It is not a pleasant world of warcraft power leveling thing to look back on world of warcraft power leveling that. But I know I world of warcraft power leveling must learn something from it,world of warcraft leveling no matter what it is, world of warcraft leveling happiness or sorrow.Our wow gold love did not go on so smoothly and we went through many things.

Sara Reid said...

JavaServer Faces technology establishes the standard for building server-side user interfaces. With the contributions of the expert group, the JavaServer Faces APIs are being designed so that they can be leveraged by tools that will make web application development even easier.

vitamin c

zXc said...

Gucci black bag
order burberry check tote
order bottega
buy anya hindmarch
purchase dolce & gabbana bag
purchase miu miu red wallet
buy valentino beige snakeskin
Another significant matter that makes cocker wearable nonsuch is when they are made of virgin innate material. Organic coddle outfits are extremely recommended by near experts as they are rubber and balmy on infants' fragile pelt. They are constitutional as they were crafted with 100% lifelike material that comes from plants grownup without victimization any pesticides, antibiotics, and over-the-counter chemical-based solutions.
2. Consider the sizing of habiliment. Sizes of cosset apparel deviate unlike manufacturers that differentiate on babe enclothe. When purchasing, prefer a sizing that is larger than his/her baby age. This would besides pee-pee sensation if hither's a lot of wear the mom has standard from former guests. This plainly substance yours leave decidedly get ill-used as babe couldn't suffer too many larger sizes of clothes given during the baby shower.
buy chanel bronze
order marc jacobs
buy salvatore ferragamos
buy mulberry grey hobo
purchase balenciaga purple
buy jimmy choo

fender said...

It's a good thing they decided to develop it for better version. File system will be more precise.
arginine