• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Need to Make Title attribute of Div Container Dynamic

 
Ranch Hand
Posts: 2259
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: 67752
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: 28325
210
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.
 
I found some pretty shells, some sea glass and this lovely tiny 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