• 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

Need a rollover effect when UIComponent is disabled and vice versa

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Friends,

I have the following situation, I need to change the background image (or src url of a <img> that is enclosed within s:link)of a s:link, when its property "Disabled" is true and vice versa. Is there a way to do it elegantly with JSF 1.2, without using a script language such as Java Script:
Here is a little snippet of my code:


So I want to change the images when switching between s:link disabled states.

Thank you in advanced.
 
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
Your expressions aren't the normal EL for JavaScript. I don't know if that's because you're using some other expression process or if you just don't understand JSF's use of the Unified Expression Language.

Here's an example of a link whose background image can be made to vary (using standard EL):


You can also use a variable styleClass on the link itself. The Image URL property can be set to something like "/images/FirstPageEnabled.jpg and /images/FirstPageDisabled.jpg or whatever you're using.

Incidentally, when doing paging, I normally define discrete methods for the boundaries - isFirstPage(), isLastPage() and so forth. It allows me to keep the amount of logic on the JSF view itself to a minimum.

Of course, since most of the extended JSF tagsets already have a paging control available out of the box, I haven't written any lately. It's easier to use one that's pre-debugged and ready.
 
Jakim Rachev
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,

Thanks for the replay. I'm pretty new with JSF. I for the Java script EL that is what I'm trying to avoid. I don't want to use java script in my project. And for the styleClass property method i got stuck because there is not such event that rices whenever a link is disabled ( no onDisabled). But Actually I solve the problem very easy:


I don't know if this way is the right way, but for now it works.
 
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
JavaScript is not EL. EL runs on the server. JavaScript runs on the client. They are 2 different languages, with only superficial syntactical similarities. There is zero benefit - or more accurately, negative benefit - to avoiding EL in JSF. It's an integral part of JSF, and in modern-day J2EE servers the support is built into the appserver itself, even for minimalist servers like Tomcat.

Also, there's a BIG difference between the "$" EL dereferencing operator and the "#" EL dereferencing operator. "$" is rarely used in JSF because of that.
 
Jakim Rachev
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I know that Java Script is client side script language, and i know its concepts. How ever it seems that I need to read some more info about JSF EL. Thanks Tim.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic