File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes creating objects in xhtml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "creating objects in xhtml" Watch "creating objects in xhtml" New topic

creating objects in xhtml

Arun Kathare

Joined: Oct 02, 2006
Posts: 19
I am working on a migration project we are migrating from jsf 1.0 to 2.0.
I the old code there were lot of scriplets present we need to migrate them to xhtml file
I am facing an issue related to create a new object in xhtml file. How do i create a new object(UserDefined) in xhtml file using jstl or jsf tag library.

Thanks In Advance.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

Using Scriptlets even in non-JSF code is something that will make some of our other moderators growl at you. It's not good practice for J2EE. Scriptlets are mostly a legacy from when J2EE was a lot less capable, and while they can still be occasionally useful, more often they cause more problems than they solve.

In JSF the problem is even more extreme. Although in the original JSF design, the HTML was processed by JSPs, there were serious limitations to this approach. This lead to the development of an alternative view technology called Facelets. Unlike the original JSF, Facelets views are NOT JSPs. Facelets Views are defined in an xhtml format known as View Definition Language (VDL) or sometimes as View Template Language (VTL). As of JSF Version 2, JSPs are no longer supported and VDL is the only standards-sanctioned way of defining JSF Views.

In both the old JSP case and the new VDL case, the View Definition was ultimately mapped to a UIComponent tree. The primary difference is that a JSP compiles into a servlet, which is a linear sequence of code. VDL, however, maps a 2-dimensional page prototype against the 2-dimensional UIComponent tree and the internal JSF logic is no longer constrained to linear sequences. It can, if the implementer so desires, process multiple sections of HTML in parallel, which would effectively reduce any view-based programming models to minced meat.

So, in short, you really need to move all that scriptlet logic into backing beans where its execution will function better.

Also, please avoid attempting to convert the scriptlets into EL. Logic on the view definition violates the Separation of Concerns contract of Model/View/Controller, and in more practical terms is A) agony to debug and B) means that maintenance costs will be higher because the maintenance programmers will constantly have to go on "treasure hunts" to find and match up code. Putting the logic in the Model (backing bean) makes things much cleaner and easier to maintain.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: creating objects in xhtml
It's not a secret anymore!