You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by dushyant agarwal <ag...@yahoo.co.in> on 2008/07/04 12:16:52 UTC

[TRINIDAD]Issue:Unable to set DateTimeConverter with tr:inputDate component from the backing bean

Hi,
 I have JSF page which contains a tr:inputDate component as given
 below:-

 <tr:inputDate
  binding="#{BB.inputDate1}"/>
 As well as there is a commandButton
 <tr:commandButton action="#{BB.action}"/>

 In the Backing bean the action method is as follows:-
 public String action(){

 DateTimeConverter converter = new DateTimeConverter();//the
 Trinidad
 DateTime Converter

  converter.setPattern("dd/MM/yyyy");
 inputDate1.setConverter(converter);
 return null;

 }

Then I tried using

<tr:inputDate converter="#{BB.dateConverter}" />

public Converter getDateConverter() {
  DateTimeConverter converter = new DateTimeConverter();//the Trinidad
DateTime Converter
  converter.setPattern("dd/MM/yyyy");
  return converter;
}

 While running the JSF page, on clicking the button the converter
 does
 get
 applied, But after the Page gets rendered if the user again clicks
 on
 the
 calendar button to select a new date then a javascript error
 appears
[Got this info on using firebug for debugging]

_getDateFieldFormat(input#inputDate1.af_inputDate_content)
_dfsv(input#inputDate1.af_inputDate_content,1217411811404)
 returnCalendarvalue(Window,undefined)
_checkUnload(undefined)
_selectdate(1217356200000)
onclick(click client X=1842, client Y =1842)
Common1_2_4.js line 2170

This error appear in the popup window where the calendar gets rendered
 
 How can I set
  the above mentioned
 converter
 on the inputDate cpmponent from the backing bean.

 The scope of the BB bean request.

 pl. consider that I strictly need to set the converter from  the
 backing bean.(Beacause sometimes the component gets generated dynamically. so 
 no way to put tr:convertDateTime  )

Thanks,
Dushyant




      Bring your gang together. Do your thing. Find your favourite Yahoo! group at http://in.promos.yahoo.com/groups/

Re: [TRINIDAD]Issue:Unable to set DateTimeConverter with tr:inputDate component from the backing bean

Posted by Matthias Wessendorf <ma...@apache.org>.
Not a bug.
Works fine with the recent trunk.

Do this in your action:

DateTimeConverter converter = (DateTimeConverter)
FacesContext.getCurrentInstance().getApplication().createConverter(Date.class);
converter.setPattern("dd/MM/yyyy");
date.setConverter(converter);

Trinidad itself registers the "correct" DateTimeConverter for the
classes Date and calendar.
So, using this syntax is much more safe.

I guess you were using the one from the API JAR, but actually that guy
that provides the client-side JS, is an extended DateTimeConverter,
that extends the one from the API. And... to not have dependency to
-IMPL in your app, this is the second reason to use the
.createConverter() method,
offered by the JSF spec itself.



On Fri, Jul 4, 2008 at 12:16 PM, dushyant agarwal
<ag...@yahoo.co.in> wrote:
> Hi,
>  I have JSF page which contains a tr:inputDate component as given
>  below:-
>
>  <tr:inputDate
>   binding="#{BB.inputDate1}"/>
>  As well as there is a commandButton
>  <tr:commandButton action="#{BB.action}"/>
>
>  In the Backing bean the action method is as follows:-
>  public String action(){
>
>  DateTimeConverter converter = new DateTimeConverter();//the
>  Trinidad
>  DateTime Converter
>
>   converter.setPattern("dd/MM/yyyy");
>  inputDate1.setConverter(converter);
>  return null;
>
>  }
>
> Then I tried using
>
> <tr:inputDate converter="#{BB.dateConverter}" />
>
> public Converter getDateConverter() {
>   DateTimeConverter converter = new DateTimeConverter();//the Trinidad
> DateTime Converter
>   converter.setPattern("dd/MM/yyyy");
>   return converter;
> }
>
>  While running the JSF page, on clicking the button the converter
>  does
>  get
>  applied, But after the Page gets rendered if the user again clicks
>  on
>  the
>  calendar button to select a new date then a javascript error
>  appears
> [Got this info on using firebug for debugging]
>
> _getDateFieldFormat(input#inputDate1.af_inputDate_content)
> _dfsv(input#inputDate1.af_inputDate_content,1217411811404)
>  returnCalendarvalue(Window,undefined)
> _checkUnload(undefined)
> _selectdate(1217356200000)
> onclick(click client X=1842, client Y =1842)
> Common1_2_4.js line 2170
>
> This error appear in the popup window where the calendar gets rendered
>
>  How can I set
>   the above mentioned
>  converter
>  on the inputDate cpmponent from the backing bean.
>
>  The scope of the BB bean request.
>
>  pl. consider that I strictly need to set the converter from  the
>  backing bean.(Beacause sometimes the component gets generated dynamically.
> so
>  no way to put tr:convertDateTime  )
>
> Thanks,
> Dushyant
>
>
> ________________________________
> Download prohibited? No problem. CHAT from any browser, without download.



-- 
Matthias Wessendorf

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
mail: matzew-at-apache-dot-org