• 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

Which one is best: <h:form binding={}> or <f:event listener="#{}" type="preRenderView" />

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have planned to assign default values to some fields when the page loading time. There is two approach available.

My Question is Which one is best (Performance wise) ?

Approach 1: Binding


Approach 2: <f:event listener="#{}" type="preRenderView" />


The details code here based on login page:
Approach 1: Binding --> Detail code
login.xhtml


Login.java --> for Approach 1



Approach 2: f:event type="preRenderView"--> Detail code
login.xhtml


Login.java --> for Approach 2


I am creating simple page to register the students details. The same page is used to edit & view the student details.
Based on the operation, i need to populate the values into fields while page loading.

I am bit confused which approach i have to select. which one is best approach?


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
We've got a whole forum where people will admonish you not to to attempt premature optimisation. It's always better to write clean code, then analyse and optimise it if it needs it than to create some baroque expensive construct that optimises stuff that doesn't need optimisation and/or gets in the way of true optimisation.

Actually, if high-speed logins are what you want, you probably will do much, much better not writing a login in JSF at all. Use the J2EE standard login services. They don't go through all the fuss about running the FacesServlet, mucking about with Component Trees or even general application overhead, since the container itself is handling the login.

Besides, of all the user-designed login/security systems I've seen since before even JSPs were invented, almost 100% of them had security flaws. Most, in fact, could be bypassed by non-technical people in 10 minutes or less. The standard security system is long since debugged, it's well-documented, and if it has ever been broken, no one told me about it.
 
Robert Jack
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim Holloway, Thanks for your effort and reply.

My object is not focused login process. I am concentrating how load the values while page loading.
When the page loading, username & password fields need to clear or show some default values.

Here i will write another one example:

I have created one page to register the students details. The same page is used to edit & view the student details.
Based on the operation, i need to populate the values into fields while page loading.

When we go to the registeration: All text fileds are empty and enable the fields.
When we go to the view the details: All text fields values are fetch from DB and components should be disabled.
When we go to the edit: All text fields values are fetch from DB and fields allow to edit.

Based on above condition, i have used both approaches, such as <h:form binding=#{}> and <f:event listener="#{}" type="preRenderView" />


Here i am confused which option is best. Actual My sample code have muliple lines. Thats why i didnt post the code here. So i post simple login page.

 
Tim Holloway
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
Once again, it's dangerous (and expensive) to "optimise" web applications without measuring where their actual bad performance areas are.

I don't have any webapps at all that do either of these things and I've been using JSF since it went live circa 2006.

JSF is based on the Model/View/Controller paradigm, and under MVC, when a page (or page part) is rendered, JSF will automatically set the rendered control values to whatever values the corresponding properties of the backing bean(s) have. There's no need for fancy JSF-specific logic and the View Template doesn't need binding or fancy listener options to make it happen. Just basic core JSF control elements.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic