115 total views, 4 views today

JSF OutputScript Example

 

The JSF OutputScript renders an HTML <SCRIPT> tag of style ‘text/javascript’. Below is the JSF tag and its corresponding HTML tag

JSF => <h:outputScript name=”js/index.js” />

HTML => <script type=”text/javascript” src=”/JSF_OutputScript_Example/faces/javax.faces.resource/js/index.js” />

 

The below example explains how the OutputScript with an example:

 

JSF h:outputScript Example

 

The JavaScript files should present under the resources folder under WebContent directory. Here below I have shown the JavaScript file and a JSF file. I explained the highlighted area below:

 

Highlight 1). The javascript js/index.js file present under the resources folder

Highlight 2). Included the index.js file in a JSF page using <h:outputScript>

Highlight 3). Calling the doalert() method present the index.js file on button click

 

112317_2059_JSFOutputSc1 JSF OutputScript Example

 

 

Below is the doalert() method in the javascript file.

 

112317_2059_JSFOutputSc2 JSF OutputScript Example

 

Below is how the page looks like in the browser

 

JSF_outputScript_Example JSF OutputScript Example

 

Download the JSF Project:


 

govindan JSF OutputScript Example
Connect me

Govind

Thank you for visiting my personal blog. Myself Govindan, Software Developer by profession since 2006 and hence I started this blog early in 2016 and ever since I've been writing about technologies experienced and learnings of everyday life.

The views expressed on this blog are my personal views and do not necessarily reflect the views of my employer.

Please feeling free to reach me on any comments and feedbacks you have. Would be more than glad to listen and reply šŸ™‚
govindan JSF OutputScript Example
Connect me
By | 2017-11-23T16:06:54+00:00 November 23rd, 2017|Categories: JSF|Tags: , , , |0 Comments
Like us on Facebook.
Connect!