• 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
  • Tim Cooke
  • Ron McLeod
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

Need to Make Title attribute of Div Container Dynamic

 
Ranch Hand
Posts: 2291
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am attempting to make the title of a div container dynamic based on specific value.
Using the following script when I hover over the container if the value == 2 I get "First" otherwise I get "class".

 
Sheriff
Posts: 67759
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you look at the generated HTML you should see the problem.












Spoiler:
No quotes around the attribute value so only the first word is parsed as part of the value.
 
Saloon Keeper
Posts: 28997
214
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
I had to look at this pretty carefully to make sense of that answer.

More accurately, the entire title attribute value needs to be quoted, including the EL code. Use single-quotes to delimit the string result.

This is one reason why I recommend not doing anything complicated in EL on a web page. A much safer/cleaner way would have been to eliminate the conditional EL and literal string and do something like this:

Where the property value for divTitle in backing bean "itemStatusV80obj" would be set to the desired title (or an empty string). The name "itemStatusV80obj", incidentally, is all sorts of ugly, since "obj" is basically redundant and a version number is questionable. Usually "itemStatus" would be enough.

Note that if you want to, you can use an alternate backing bean to hold the "divTitle" property if it would be inappropriate to put it in the itemStatus object.
 
Beauty is in the eye of the tiny ad.
The new gardening playing cards kickstarter is now live!
https://www.kickstarter.com/projects/paulwheaton/garden-cards
reply
    Bookmark Topic Watch Topic
  • New Topic