You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Aaron Bartell <al...@gmail.com> on 2005/05/09 23:17:21 UTC
inputDate
After reading the documentation for inputDate
(http://myfaces.apache.org/tlddoc/) I found that the 'value' attribute is
only used for the initial value when the component is rendered for the first
time. Why is this so? I have a need to change the date programmatically
based on another field changing on the screen (coupled with a post back to
server) but the way this component is set to work makes it so it can't be
set to a different value.
Any comments?
Thanks,
Aaron Bartell
Re: inputDate
Posted by Martin Marinschek <ma...@gmail.com>.
By the way..
the value description you found in the tlddoc is inherited from up in
the component hierarchi, so all components share that description for
the value attribute in their tlddoc.
regards,
Martin
2005/5/19, Martin Marinschek <ma...@gmail.com>:
> Hi Aaron,
>
> that is the same with all components in JSF - they read out the value
> the first time they render itself and subsequently use the submitted
> value which is posted back from the component.
>
> If you want to make sure that the value is newly read by the
> component, you might want to reset the submitted value.
>
> regards,
>
> Martin
>
> 2005/5/18, Aaron Bartell <al...@gmail.com>:
> > I have looked into this some more and am trying to figure out what
> > determines when a object that extends HtmlInputText will have the
> > getter property called for each round trip to the server. Is there a
> > setting some where that makes it so <x:inputDate> (a.k.a.
> > HtmlInputCalendar) doesn't have it's getter property called for
> > subsequent round trips after the initial page load?
> >
> > I started looking at the MyFaces code base, but couldn't find where
> > that would be specified. From what I can tell here is the inheritance
> > structure:
> >
> > javax.faces.component.UIOutput
> > javax.faces.component.UIInput
> > javax.faces.component.html.HtmlInputText
> > org.apache.myfaces.custom.calendar.HtmlInputCalendar
> >
> > I do not have an intimate knowledge of JSF innerds yet so if somebody
> > could help me out I would be much appreciative. Basically I am just
> > looking for a way to update a <h:inputCalendar> field after the
> > initial page load. I have tried using the binding attribute thinking
> > I might have some additional control from that avenue, but it still
> > only calls the getter property on the initial page load and not
> > subsequent page loads.
> >
> > Thanks in advance,
> > Aaron Bartell
> > http://mowyourlawn.com
> >
> >
> > On 5/9/05, Aaron Bartell <al...@gmail.com> wrote:
> > >
> > >
> > >
> > > After reading the documentation for inputDate
> > > (http://myfaces.apache.org/tlddoc/) I found that the
> > > 'value' attribute is only used for the initial value when the component is
> > > rendered for the first time. Why is this so? I have a need to change the
> > > date programmatically based on another field changing on the screen (coupled
> > > with a post back to server) but the way this component is set to work makes
> > > it so it can't be set to a different value.
> > >
> > >
> > >
> > > Any comments?
> > >
> > >
> > >
> > > Thanks,
> > >
> > > Aaron Bartell
> > >
> > >
> > >
> > >
> >
>
Re: inputDate
Posted by Martin Marinschek <ma...@gmail.com>.
Hi Aaron,
that is the same with all components in JSF - they read out the value
the first time they render itself and subsequently use the submitted
value which is posted back from the component.
If you want to make sure that the value is newly read by the
component, you might want to reset the submitted value.
regards,
Martin
2005/5/18, Aaron Bartell <al...@gmail.com>:
> I have looked into this some more and am trying to figure out what
> determines when a object that extends HtmlInputText will have the
> getter property called for each round trip to the server. Is there a
> setting some where that makes it so <x:inputDate> (a.k.a.
> HtmlInputCalendar) doesn't have it's getter property called for
> subsequent round trips after the initial page load?
>
> I started looking at the MyFaces code base, but couldn't find where
> that would be specified. From what I can tell here is the inheritance
> structure:
>
> javax.faces.component.UIOutput
> javax.faces.component.UIInput
> javax.faces.component.html.HtmlInputText
> org.apache.myfaces.custom.calendar.HtmlInputCalendar
>
> I do not have an intimate knowledge of JSF innerds yet so if somebody
> could help me out I would be much appreciative. Basically I am just
> looking for a way to update a <h:inputCalendar> field after the
> initial page load. I have tried using the binding attribute thinking
> I might have some additional control from that avenue, but it still
> only calls the getter property on the initial page load and not
> subsequent page loads.
>
> Thanks in advance,
> Aaron Bartell
> http://mowyourlawn.com
>
>
> On 5/9/05, Aaron Bartell <al...@gmail.com> wrote:
> >
> >
> >
> > After reading the documentation for inputDate
> > (http://myfaces.apache.org/tlddoc/) I found that the
> > 'value' attribute is only used for the initial value when the component is
> > rendered for the first time. Why is this so? I have a need to change the
> > date programmatically based on another field changing on the screen (coupled
> > with a post back to server) but the way this component is set to work makes
> > it so it can't be set to a different value.
> >
> >
> >
> > Any comments?
> >
> >
> >
> > Thanks,
> >
> > Aaron Bartell
> >
> >
> >
> >
>
RE: inputDate
Posted by albartell <al...@gmail.com>.
The first round of code that I posted for the Archives is incorrect (sorry
about that). Here is code that will work. The scenario is that a user
selected something from a drop down and an event was fired to this method.
Pay special attention to where I find the component and then cast it to an
EditableValueHolder object so the setSubmittedValue() method can get called
(which is the key to the new value getting redisplayed).
public String changeDeliverMethodVCE(ValueChangeEvent event) {
Integer delivermethoduid = (Integer) event.getNewValue();
Delivermethod dm = Delivermethod.getExact(delivermethoduid);
if (dm.getDefaultdaysout().intValue() > 0) {
Calendar now = Calendar.getInstance();
now.add(Calendar.DAY_OF_MONTH,
dm.getDefaultdaysout().intValue());
curOrder.setDeliverby(now.getTime());
FacesContext fc = FacesContext.getCurrentInstance();
UIComponent dlvby = (UIComponent)
fc.getViewRoot().findComponent("form1:deliverby");
if (dlvby != null) {
EditableValueHolder evh = (EditableValueHolder) dlvby;
evh.setSubmittedValue(null);
evh.setValue(curOrder.getDeliverby());
}
}
return null;
}
Aaron Bartell
-----Original Message-----
From: Aaron Bartell [mailto:albartell@gmail.com]
Sent: Monday, May 23, 2005 11:18 AM
To: MyFaces Discussion
Subject: Re: inputDate
That worked Jon, thanks.
For the archives in case somebody else needs to know how to do this,
here is how I accomplished the task of resetting a form variable.
jsp code:
<x:inputCalendar id="deliverby"
monthYearRowClass="yearMonthHeader"
weekRowClass="weekHeader"
currentDayCellClass="currentDayCell"
value="#{OrderCtl.curOrder.deliverby}"
renderAsPopup="true"
rendered="true"
required="true"
styleClass="input"/>
Backing bean code:
FacesContext fc = FacesContext.getCurrentInstance();
fc.getApplication().createValueBinding("#{OrderCtl.curOrder.deliverby}").set
Value(fc,
null);
Aaron Bartell
On 5/18/05, Jon Travis <jt...@p00p.org> wrote:
> Aaron,
>
> This seems like a popular problem with JSF. I'll assume you're
> using a value-binding for the value of your component. What
> we're doing when we want the page to refresh it's value from
> the backing bean is to just do component.setValue(null), and
> component.setSubmittedValue(null)
>
> Give that a whack. Would be nice to have a 'best practices'
> or FAQ page for JSF developers -- stuff like this would sit
> at the top.
>
> -- Jon
>
>
>
> On May 18, 2005, at 2:09 PM, Aaron Bartell wrote:
>
> > I have looked into this some more and am trying to figure out what
> > determines when a object that extends HtmlInputText will have the
> > getter property called for each round trip to the server. Is there a
> > setting some where that makes it so <x:inputDate> (a.k.a.
> > HtmlInputCalendar) doesn't have it's getter property called for
> > subsequent round trips after the initial page load?
> >
> > I started looking at the MyFaces code base, but couldn't find where
> > that would be specified. From what I can tell here is the inheritance
> > structure:
> >
> > javax.faces.component.UIOutput
> > javax.faces.component.UIInput
> > javax.faces.component.html.HtmlInputText
> > org.apache.myfaces.custom.calendar.HtmlInputCalendar
> >
> > I do not have an intimate knowledge of JSF innerds yet so if somebody
> > could help me out I would be much appreciative. Basically I am just
> > looking for a way to update a <h:inputCalendar> field after the
> > initial page load. I have tried using the binding attribute thinking
> > I might have some additional control from that avenue, but it still
> > only calls the getter property on the initial page load and not
> > subsequent page loads.
> >
> > Thanks in advance,
> > Aaron Bartell
> > http://mowyourlawn.com
> >
> >
> > On 5/9/05, Aaron Bartell <al...@gmail.com> wrote:
> >
> >>
> >>
> >>
> >> After reading the documentation for inputDate
> >> (http://myfaces.apache.org/tlddoc/) I found that the
> >> 'value' attribute is only used for the initial value when the
> >> component is
> >> rendered for the first time. Why is this so? I have a need to
> >> change the
> >> date programmatically based on another field changing on the
> >> screen (coupled
> >> with a post back to server) but the way this component is set to
> >> work makes
> >> it so it can't be set to a different value.
> >>
> >>
> >>
> >> Any comments?
> >>
> >>
> >>
> >> Thanks,
> >>
> >> Aaron Bartell
> >>
> >>
> >>
> >>
> >>
> >
> >
> >
>
>
>
Re: inputDate
Posted by Aaron Bartell <al...@gmail.com>.
That worked Jon, thanks.
For the archives in case somebody else needs to know how to do this,
here is how I accomplished the task of resetting a form variable.
jsp code:
<x:inputCalendar id="deliverby"
monthYearRowClass="yearMonthHeader"
weekRowClass="weekHeader"
currentDayCellClass="currentDayCell"
value="#{OrderCtl.curOrder.deliverby}"
renderAsPopup="true"
rendered="true"
required="true"
styleClass="input"/>
Backing bean code:
FacesContext fc = FacesContext.getCurrentInstance();
fc.getApplication().createValueBinding("#{OrderCtl.curOrder.deliverby}").setValue(fc,
null);
Aaron Bartell
On 5/18/05, Jon Travis <jt...@p00p.org> wrote:
> Aaron,
>
> This seems like a popular problem with JSF. I'll assume you're
> using a value-binding for the value of your component. What
> we're doing when we want the page to refresh it's value from
> the backing bean is to just do component.setValue(null), and
> component.setSubmittedValue(null)
>
> Give that a whack. Would be nice to have a 'best practices'
> or FAQ page for JSF developers -- stuff like this would sit
> at the top.
>
> -- Jon
>
>
>
> On May 18, 2005, at 2:09 PM, Aaron Bartell wrote:
>
> > I have looked into this some more and am trying to figure out what
> > determines when a object that extends HtmlInputText will have the
> > getter property called for each round trip to the server. Is there a
> > setting some where that makes it so <x:inputDate> (a.k.a.
> > HtmlInputCalendar) doesn't have it's getter property called for
> > subsequent round trips after the initial page load?
> >
> > I started looking at the MyFaces code base, but couldn't find where
> > that would be specified. From what I can tell here is the inheritance
> > structure:
> >
> > javax.faces.component.UIOutput
> > javax.faces.component.UIInput
> > javax.faces.component.html.HtmlInputText
> > org.apache.myfaces.custom.calendar.HtmlInputCalendar
> >
> > I do not have an intimate knowledge of JSF innerds yet so if somebody
> > could help me out I would be much appreciative. Basically I am just
> > looking for a way to update a <h:inputCalendar> field after the
> > initial page load. I have tried using the binding attribute thinking
> > I might have some additional control from that avenue, but it still
> > only calls the getter property on the initial page load and not
> > subsequent page loads.
> >
> > Thanks in advance,
> > Aaron Bartell
> > http://mowyourlawn.com
> >
> >
> > On 5/9/05, Aaron Bartell <al...@gmail.com> wrote:
> >
> >>
> >>
> >>
> >> After reading the documentation for inputDate
> >> (http://myfaces.apache.org/tlddoc/) I found that the
> >> 'value' attribute is only used for the initial value when the
> >> component is
> >> rendered for the first time. Why is this so? I have a need to
> >> change the
> >> date programmatically based on another field changing on the
> >> screen (coupled
> >> with a post back to server) but the way this component is set to
> >> work makes
> >> it so it can't be set to a different value.
> >>
> >>
> >>
> >> Any comments?
> >>
> >>
> >>
> >> Thanks,
> >>
> >> Aaron Bartell
> >>
> >>
> >>
> >>
> >>
> >
> >
> >
>
>
>
Re: inputDate
Posted by Jon Travis <jt...@p00p.org>.
Aaron,
This seems like a popular problem with JSF. I'll assume you're
using a value-binding for the value of your component. What
we're doing when we want the page to refresh it's value from
the backing bean is to just do component.setValue(null), and
component.setSubmittedValue(null)
Give that a whack. Would be nice to have a 'best practices'
or FAQ page for JSF developers -- stuff like this would sit
at the top.
-- Jon
On May 18, 2005, at 2:09 PM, Aaron Bartell wrote:
> I have looked into this some more and am trying to figure out what
> determines when a object that extends HtmlInputText will have the
> getter property called for each round trip to the server. Is there a
> setting some where that makes it so <x:inputDate> (a.k.a.
> HtmlInputCalendar) doesn't have it's getter property called for
> subsequent round trips after the initial page load?
>
> I started looking at the MyFaces code base, but couldn't find where
> that would be specified. From what I can tell here is the inheritance
> structure:
>
> javax.faces.component.UIOutput
> javax.faces.component.UIInput
> javax.faces.component.html.HtmlInputText
> org.apache.myfaces.custom.calendar.HtmlInputCalendar
>
> I do not have an intimate knowledge of JSF innerds yet so if somebody
> could help me out I would be much appreciative. Basically I am just
> looking for a way to update a <h:inputCalendar> field after the
> initial page load. I have tried using the binding attribute thinking
> I might have some additional control from that avenue, but it still
> only calls the getter property on the initial page load and not
> subsequent page loads.
>
> Thanks in advance,
> Aaron Bartell
> http://mowyourlawn.com
>
>
> On 5/9/05, Aaron Bartell <al...@gmail.com> wrote:
>
>>
>>
>>
>> After reading the documentation for inputDate
>> (http://myfaces.apache.org/tlddoc/) I found that the
>> 'value' attribute is only used for the initial value when the
>> component is
>> rendered for the first time. Why is this so? I have a need to
>> change the
>> date programmatically based on another field changing on the
>> screen (coupled
>> with a post back to server) but the way this component is set to
>> work makes
>> it so it can't be set to a different value.
>>
>>
>>
>> Any comments?
>>
>>
>>
>> Thanks,
>>
>> Aaron Bartell
>>
>>
>>
>>
>>
>
>
>
Re: inputDate
Posted by Aaron Bartell <al...@gmail.com>.
I have looked into this some more and am trying to figure out what
determines when a object that extends HtmlInputText will have the
getter property called for each round trip to the server. Is there a
setting some where that makes it so <x:inputDate> (a.k.a.
HtmlInputCalendar) doesn't have it's getter property called for
subsequent round trips after the initial page load?
I started looking at the MyFaces code base, but couldn't find where
that would be specified. From what I can tell here is the inheritance
structure:
javax.faces.component.UIOutput
javax.faces.component.UIInput
javax.faces.component.html.HtmlInputText
org.apache.myfaces.custom.calendar.HtmlInputCalendar
I do not have an intimate knowledge of JSF innerds yet so if somebody
could help me out I would be much appreciative. Basically I am just
looking for a way to update a <h:inputCalendar> field after the
initial page load. I have tried using the binding attribute thinking
I might have some additional control from that avenue, but it still
only calls the getter property on the initial page load and not
subsequent page loads.
Thanks in advance,
Aaron Bartell
http://mowyourlawn.com
On 5/9/05, Aaron Bartell <al...@gmail.com> wrote:
>
>
>
> After reading the documentation for inputDate
> (http://myfaces.apache.org/tlddoc/) I found that the
> 'value' attribute is only used for the initial value when the component is
> rendered for the first time. Why is this so? I have a need to change the
> date programmatically based on another field changing on the screen (coupled
> with a post back to server) but the way this component is set to work makes
> it so it can't be set to a different value.
>
>
>
> Any comments?
>
>
>
> Thanks,
>
> Aaron Bartell
>
>
>
>