Showing posts with label Parameter. Show all posts
Showing posts with label Parameter. Show all posts

Wednesday, January 21, 2009

Pass action as Facelets-Parameter

There is a problem to pass an action as a Facelet-Parameter to a Fragment via ui:include an ui:param.
With the J4Fry-Action-Wrapper (http://www.j4fry.org/jsfErrorhandling.shtml) as a part of the J4Fry-JSF-Components (http://www.j4fry.org/jsfComponents.shtml) you've got the possibility to pass the action (e.g. for a h:commandButton) to a Facelets-Fragment.

Example
Main-Page

...
<ui:include src="Fragments/myFragment.xhtml">
<ui:param name="myAction" value="myBean.doSomething" />
</ui:include>
...

Fragment

<h:commandButton value="Execute doSomething" action="#{action[myAction].trigger}" />

To use that solution you have to download the J4Fry-JSF-Components (with dependencies described here: http://www.j4fry.org/jsfComponents.shtml) and place the JAR-File into your lib-directory from the webapplication. Thats it!

Saturday, January 10, 2009

Facelets Template-Parameter

Es gibt mehrere Möglichkeiten Facelets-Templates zu parameterisieren.
  1. Über ui:insert und ui:define
  2. Über EL und ui:param
Facelets Template:

<html>
<head>
<link rel="stylesheet" type="text/css" href="#{myStylesheet}" media="screen, projection" />
</head>
<body>
<ui:insert name="myContent">No content supplied.</ui:insert>
</body>
</html>

Facelets Template-Client:

<ui:composition template="MyTemplate.xhtml">
<ui:param name="myStylesheet" value="http://my.host.com/css/style.css" />
<ui:define name="content">
<h1>My Content</h1>
</ui:define>
</ui:composition>


Über ui:insert ist es möglich Blockplatzhalter zu definieren.
Mit ui:param können auch Inline-Passagen definiert werden.

Die Frage wurde in unserem XING JSF-Developers-Forum (https://www.xing.com/net/jsf) gestellt.