Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need a rollover effect when UIComponent is disabled and vice versa

 
Jakim Rachev
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • 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.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18169
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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
Pie
Posts: 18169
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic