Hi sbalac
I will give your approach a try, but I don't think this will work since the
parameters are passed on a form submit.. i think..
In my case the parameters should be passed to the converter while rendering
the page?!
Please take a look to the standard DateTimeConverter. This Converter is
accepting attributes. Also it is possible to define attributes and
properties in Eclipse faces-config.xml Editor for converters?!
Here is an example of usage of the DateTimeConverter:
<h:outputText value="#{project.creationDate}">
<f:convertDateTime type="date" dateStyle="some style"/>
</h:outputText>
Source:
http://jsf.iatp.org.ua/converters/jsf_datetimeconverter.html
http://jsf.iatp.org.ua/converters/jsf_datetimeconverter.html
While copying the example I recognized the first time, that in that case the
tag is different!!
<f:convertDateTime>
How has this been done?
Thank you for your help!
sbalac wrote:
>
> Hi Alan,
> I'n not an expert by any means, but I have not come across <f:converter>
> tag that allows anything other than the id. I think if you want to pass
> parameters, you couls try something along the lines of :
> <f:converter converterId="GwOutTextConverter">
> <f:param id="substring" value="5" />
> </f:converter>
>
> Then in your converter you can access the parameters from the Request
> Parameter map which you can get a hold of from the faces context.
> Hope that helps
>
>
> Alan Gross wrote:
>>
>> HI Forum
>>
>> Environment info:
>> Tomcat6
>> Myfaces 1.2.2
>> Facelets 1.1.13
>>
>> I'm tring to write a flexibel string converter. The goal is to have a
>> converter that provides the following functionality
>> - substring
>> - remove newlines
>>
>> I would like to pass the parameters by attributes
>> - number of chars for substring
>> - number of newlines before truncating
>>
>> I took the standard converter DateTimeConverter as an example. But for
>> some reason I don't get it to work.
>>
>> I think the problem is that the "restoreState" method is never invoked
>> here. Also the "getAsObject" method is never invoked..? Don't know if
>> necessary? I tried to use server and client state saving method. Read it
>> could have an impact..?
>>
>> Does anyone have experience with passing parameters to converters?
>>
>> Any help is appreciated. Thank you!
>> Alan
>>
>> Attached you find the following files:
>> - faces-config.xml
>> - web.xml
>> - OutputTextConverter.java
>> http://www.nabble.com/file/p17351134/OutputTextConverter.java
>> OutputTextConverter.java
>> http://www.nabble.com/file/p17351134/faces-config.xml faces-config.xml
>> http://www.nabble.com/file/p17351134/web.xml web.xml
>>
>> Here is an extract of the page:
>> <h:outputText value="#{newsVar.description}" escape="false">
>> <f:converter converterId="GwOutTextConverter" substring="5"
>> maxNewLine="3" test="123"/>
>> </h:outputText>
>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Converter---Problem-passing-attributes-tp17351134p17366470.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.