This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes JSF and the fly likes Generating <script> tag from Custom JSF Tag Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Generating <script> tag from Custom JSF Tag" Watch "Generating <script> tag from Custom JSF Tag" New topic
Author

Generating <script> tag from Custom JSF Tag

Kashif Nazar
Greenhorn

Joined: May 15, 2009
Posts: 12
Hi,

I am new to JSF Custom Tags. I developed a Custom tag. It's quite a fun to make your own custom tags . Now I have to use some javascript for my custom components. The inline javascript calls are no issue for me. But I want my javascript be embedded in a <script> tag automatically. So that I don't have to explicitly add my javascript into <script> tag, instead, it is automatically included in the page where my tags are being used. How can this be achieved?

Regards,
Kashif


Kashif
Jason Lee
Greenhorn

Joined: Mar 03, 2008
Posts: 12
[quote=Kashif Nazar]Hi,

I am new to JSF Custom Tags. I developed a Custom tag. It's quite a fun to make your own custom tags :) . Now I have to use some javascript for my custom components. The inline javascript calls are no issue for me. But I want my javascript be embedded in a <script> tag automatically. So that I don't have to explicitly add my javascript into <script> tag, instead, it is automatically included in the page where my tags are being used. How can this be achieved?[/quote]

I'm not sure I understand your question. Are you wanting to add your custom JS to <head>? If so, you would user <h:outputScript>. If you're wanting something easier for inline JS from your composite component (which is what I'm assuming you mean by "custom tag?"), I'm not aware of anything to help there. A component for that seems like over kill. :)


Jason Lee, SCJP
Senior Member of Technical Staff with Oracle
http://blogs.steeplesoft.com
satya anvesh
Greenhorn

Joined: Sep 23, 2008
Posts: 16
Hi

I want to include a .js script in a jsf page conditionally. That is, if a bean condition is true, one.js should be included otherwise two.js should be included. I am using JSF 1.1 so it does not support 'rendered' tag in <f:verbatim>. How can I achieve this? Thanks for your help.

Anvesh
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Generating <script> tag from Custom JSF Tag
 
Similar Threads
TagLib: BodyTagSupport question
How to create JSF custom tag
rerender losing attributes of a tag
SimpleTagSupport implementation problem
custom tag library questions