-
1. Re: JSF Question about passing parameters (needing converters) to resource bundles from facelets...
ssilvert Sep 10, 2010 8:23 AM (in response to qdog1028)Hi Chris,
I took a close look at this using Mojarra 2.0. When I put a <f:converter> tag inside a <f:param> tag and I got this exception:
javax.faces.view.facelets.TagException: /index.xhtml @23,60 <f:converter> Parent not an instance of ValueHolder: javax.faces.component.UIParameter@1675bf3
According to javadoc, <f:param> doesn't support converters. However, if used with some tags, such as <h:link>, you can use the converterId attribute to pass a converter. This works:
<h:link value="Hello Link">
<f:param name="foo" value="#{myDate}" converterId="javax.faces.DateTime"/>
</h:link>The thing about <f:param> is that the parent component gets to decide how to treat it.
Anyway, I haven't looked at the code for the tag, but it looks like <h:outputFormat> won't look for converters on its <f:param> children.
I think the easiest workaround for you is to use a managed bean to do the conversion. You could just let #{widget} return the date as a string that is formatted the way you want it.
<f:param value="#{widget.convertedDate}">
If you were using JBoss AS6, you could take advantage of EL ValueExpressions with params and do something like this:
<f:param value="#{myConverterBean(widget.date)}">Another approach is to use some logic that changes the value in the component tree during the JSF lifecycle. I think that would be overly complicated though.
Stan
-
2. Re: JSF Question about passing parameters (needing converters) to resource bundles from facelets...
skotinin Apr 18, 2012 8:53 AM (in response to qdog1028)Hello!
h:outputFormat uses MessageFormat.format() for output string. See MessageFormat api documentation for information about how can convert param.
For example:
label_pos_dt_dt2=xxx "{0}-{1,date,short}" / yyy "{2}-{3,date,short}"
<h:outputFormat value="#{msg.label_pos_dt_dt2}" > <f:param value="#{CalcBean.selectedPosDt}" /> <f:param value="#{CalcBean.selectedDPosDt}" /> <f:param value="#{CalcBean.selectedPosDt2}" /> <f:param value="#{CalcBean.selectedDPosDt2}" /> </h:outputFormat>