Hobione's Weblog

Living & Breathing in Web 2.0 Era

!include vs. #include

Ken Paulsen‘s Reply:
#include staticly includes a file into your page.

<!include> (or <ui:include> in the facelets syntax) dynamically includes a file into your page. Also <!include> supports passing in parameters to the included page. For example:

test.jsf:
   <!include src="foo.jsf" foo='bar' />

foo.jsf:
“The value of foo: #{foo}

Try that.

The pro’s for #include… from JSFT’s perspective it is only 1 file and therfor id’s are never a problem. It’s also fast and efficient (the other way isn’t bad, but this one is faster).

The pro’s for <!include>, it’s dynamic so you can use #{} to determine the template name and you can pass in values. The big advantage comes from the closely related tag: <!composition> which allows you to use <!define> to pass values to a template. This is very powerful.

Let me know if you need more details.

Thanks,

Ken

Advertisements

April 16, 2008 - Posted by | Java Server Faces

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: