62 - 82
Guide to using facelets tags
Guide to using facelets templating tags
------------------------------
ui:composition
ui:decorate same as composition just that things that are outside this tag
are not ignored
ui:define where the content that should replace ui:insert from the temmplate
begins in the template client
ui:insert is the placeholder in the template file where the content should
be inserted from the template client, if no name attribute the content that is inserted is the actual content for this tag
ui:include can be placed in template clients or template. This tag supports
parameters which you can pass to the included file
Guide to using non templating tags
----------------------------------
ui:component id="optionalComponentId"
binding="managedBeanUiComponent"
if binding not provided , one will be created in the created
anything outside this tag is not included
ui:fragment
the same as ui:component except that it wraps
a series of components inside a single parent component
before is added to the tree
ui:remove used to comment a portion of the markup
ui:debug hotkey="optionalHotKey"
pressing that key will show you the component tree
is optionalKey not specified pressing ctrl-shift-d will show the popup window
Chapter 5
Managed beans the JSF EL
------------------------
@ManagedBean(name="xxx")
public class UserBean
if no name attribute the name will be userBean
can also add it in faces-config
managed-bean
managed-bean-name
managed-bean-class
manged-bean-scope
"end" managed bean
u can actually put in the page directly
#{userBean.firstName} and it will render
@ManagedProperty(value="Jane")
this is to add an initial value to a property
in the managed bean
or in faces-config
<managed-property>
<property-name>firstName</property-name>
<value>Jane</value>
</managed-property>
showing items from lists
#{userBean.sportsInterests[0]}
for maps value="#{userBean.sportsInterests['Swimming']}"
u can also declare maps or lists as managed beans
<managed-bean>
<managed-bean-name>moreSports</managed-bean-name>
<managed-bean-class>java.util.ArrayList</managed-bean-class>
<managed-bean-scope>none</managed-bean-scope>
<list-entries>
<value>Skiing</value>
<value>Tennis</value>
<value>Rollerblading</value>
</list-entries>
</managed-bean>
u can refer other managed beans in the declaration of managed beans
<list-entries>
<value>#{moreSports[0]}</value>
this is an example using annotations
@ManaqedProperty(value="#{addressBean}")
private Address homeAddress;
@ManaqedProperty(value="#{addressBean}")
private Address shippingAddress;
u can also use params from the request
<managed-property>
<property-name>userid</property-name>
<value>#{param.userid}</value>
</managed-property>
doing the same thing with annotations
@ManaqedProperty(value="#{param.userid}")
private Address userid;
Managed beans life spans
--------------------------
there is a scope which is shorter than request
#{facesContext.attributes} (u actually put this value
for scope in faces-config)
other scopes: none, request, view, session, application
request to be avoided ?!
managed beans can reference either managed beans
with the scope none or beans with greater or equal scope span.
none - @NoneScoped (will stay as long as the bean that is referencing it)
request - available only for one http request @RequestScoped
view scope - the user stays in the same view @ViewScoped
session - @SessionScoped
application - available to all users!
customscope - @CustomScoped
u can use other annotation in the BB
@PostConstruct
@PreDestroy
JSF EL
------------------------------------
#{expr} evaluated at runtime time
${expr} evaluated at compile time
used as:
value expressions
----------------------------
#{userBean.firstName}
first looks is the value of the base is one of the implicit objects in EL
first it looks in ServletRequest getAttribute("userBean")
from the UIViewRoot calls getViewMap()
from the HttpSession calls getAttribute("userBean")
if not found calls getAttribute("userBean") on the ServletContext
setting values in mb value="#{userBean.firstName}
this happens in update model values phase
the class involved is ValueExpression
-----------------------
the EL flash
flash is an implicit object in EL
flash.serviceLevel sets or gets the var sericeLevel from the flash
scope
---------------------
91 - at least 101
method expression - when an action is specified
u can't pass params to method expressions
action
actionListener
valueChangeListener
u can invoke arbitrary methods
and pass parameters to them
<h:link outcome="page02" value="Link with query parameters">
<f:param name="word1" value="hello" />
<f:param name="word2" value="dolly" />
</h:link>
How to access backing bean programatically
ELContext elContext = context.getELContext( );
Application application = context.getApplication( );
String userid = (String) application.evaluateValueExpressionGet(context,
"#{userBean.userid}",String.class);
chapter 6 - the navigation model
--------------------------------
implicit navigation
No comments:
Post a Comment