• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

creating objects in xhtml

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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.
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic