• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Similar logic:notPresent in JSF

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

I usually use struts to develop front-end applications. Recently, I am quite interested in JSF and want to know how similar to struts it is.

When I study JSF, I cannot find the tag which is similar to <logic:notPresent> tag in struts. If you know there is similar things in JSF, please let me know.


Thanks
Benson
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to our brand new JSF Forum...
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember that JSF is component oriented. So you turn components on and off. Basically you can use the rendered attribute. So you might have something like:




And then in your backing bean:



[ January 07, 2005: Message edited by: Gregg Bolinger ]
[ January 07, 2005: Message edited by: Gregg Bolinger ]
 
Benson Fung
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Gregg, so how is the corresponding JSP fragment in order to work with these two bean method?


Thanks
Benson
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check my post again. It wasn't showing up but it is there now.
 
Benson Fung
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gregg,

according to the rendered attribute :

rendered="#{backingbeans.renderHello}", the JSF will will isRenderHello or getRenderHello ?

Is it equivalent to the following JSP fragment?

<h utputText value="Hello" binding="#{backingbeans.renderHello}" rendered="false"/>


Thanks for your help actually.

Benson
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The binding and rendering attributes do 2 totally different things. The binding attribute binds the HTML compontent to an actual object in the backing bean. The rendered attribute simply tells JSF whether or not to display the component. It only takes true or false.

When speaking about booleans, it is the same in any JavaBean. Booleans aren't get and set. They are is and set. You don't "get this boolean". You say "is this boolean".
 
Benson Fung
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do I need to delcare renderHello as a managed property in faces-config.xml?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Benson Fung:
Do I need to delcare renderHello as a managed property in faces-config.xml?



Nope. Just in your backing bean.

private boolean renderHello;
 
Benson Fung
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gregg,

What is the difference between declaring the property in faces-config.xml or not?

I am very confused.


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

according to the rendered attribute :

rendered="#{backingbeans.renderHello}", the JSF will call isRenderHello or getRenderHello ?

Thanks
Benson
 
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I have a property "renderHello", irrespective of it's type I have to use getRenderHello() (not isRenderHello() ) to retrieve in JSF page.

Does "isRenderHello" works for you Gregg?
[ January 07, 2005: Message edited by: K Varun ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by K Varun:
If I have a property "renderHello", irrespective of it's type I have to use getRenderHello() (not isRenderHello() ) to retrieve in JSF page.

Does "isRenderHello" works for you Gregg?

[ January 07, 2005: Message edited by: K Varun ]



Yes, is works fine for me.
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, so that's implementation dependant, strange !!
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by K Varun:
Oh, so that's implementation dependant, strange !!



I don't see why it would be. What implementation are you using? The other thing is using isXXXX for booleans is just general JavaBean rules.
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gregg Bolinger:


I don't see why it would be. What implementation are you using? The other thing is using isXXXX for booleans is just general JavaBean rules.



I am using IBM's jsf implmentation.
If I create a boolean xxx property, the IDE create isXXX method automatically, so far so good .... but to use it in UI page, I have to change that isXXX to getXXX, else I face the error "property not found"
[ January 07, 2005: Message edited by: K Varun ]
 
Benson Fung
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gregg,

What is the difference between declaring the property in faces-config.xml or not?

I am very confused.


Thanks
Benson
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is an example of a property (id) configured in faces-config.xml

So in this case, you are initializing "id" variable of your session scoped bean with some other request scoped bean's attribute.

Also, you can configure a dBHandler managed bean class with some "configurable" values of dbUserId, dbUserPW, MaxConnections etc.

Similarly, there are many other benefits, I hope you've must got the basic point.
[ January 07, 2005: Message edited by: K Varun ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by K Varun:


I am using IBM's jsf implmentation.
If I create a boolean xxx property, the IDE create isXXX method automatically, so far so good .... but to use it in UI page, I have to change that isXXX to getXXX, else I face the error "property not found"

[ January 07, 2005: Message edited by: K Varun ]



That's messed and a bad implementation IMO.
 
Benson Fung
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Varun,

How about like this?

<managed-bean><managed-bean-name>someSessionBean</managed-bean-name><managed-bean-class>somepackage.someSessionBean</managed-bean-class><managed-bean-scope>session</managed-bean-scope><managed-property><property-name>id</property-name>
<property-class>String</property-class>
</managed-property>
</managed-bean>

In this fragment, why I need to declare in faces-config.xml and specify its class type?


Thanks
Benson
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you are right, there isn't any need. Just declaring it as a managed bean's would do it.
 
Evil is afoot. But this tiny ad is just an ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic