This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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.
An IDE is no substitute for an Intelligent Developer.
Joined: Sep 04, 2010
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.
Also, there's a BIG difference between the "$" EL dereferencing operator and the "#" EL dereferencing operator. "$" is rarely used in JSF because of that.
Joined: Sep 04, 2010
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.