You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by lw...@att.net on 2009/12/18 22:44:42 UTC

how to restrict inputDate to be the 1st date of each month within a range of date

Hi,
 with the following code, I don't think it suits my need.  Please advise if there is way to achieve only allowing 1st day of each month within a certain range, say within Oct 15, 2008 - Oct 30, 2010 to be selectable.  If this is not possible, backend validation is the only choice.

 <tr:inputDate id="days" value="#{bean.date}"
                                  label="Select a date, but check possible holidays first">
                <tr:convertDateTime pattern="yyyy-MM-dd"/>
                <tr:validateDateRestriction  invalidDays="#{bean.date.nationalHolidays}" />
              </tr:inputDate>

Re: how to restrict inputDate to be the 1st date of each month within a range of date

Posted by Maurice Kienenberger <mk...@gmail.com>.
Probably because it's easier to pick using one component than two.

Maybe he could try using

    <tr:convertDateTime pattern="yyyy-MM"/>

and see if that will automatically set the day part to 01 no matter
which day is picked.

If he wanted something different,  another option is an
h:selectOneMenu that listed yyyy-MM rather than two separate
components.

On Mon, Dec 21, 2009 at 2:25 PM, Jakob Korherr <ja...@gmail.com> wrote:
> Hi,
>
> Why do you want to select only the 1st day of each month? do you want to
> select a month with this component? If so, why don't you just use two
> <h:selectOneMenu> components, one for the month and one for the year?
>
> Regards,
>
> Jakob Korherr
>
> 2009/12/18 <lw...@att.net>
>
>>  Hi,
>>  with the following code, I don't think it suits my need.  Please advise if
>> there is way to achieve only allowing 1st day of each month within a certain
>> range, say within Oct 15, 2008 - Oct 30, 2010 to be selectable.  If this is
>> not possible, backend validation is the only choice.
>>
>>  <tr:inputDate id="days" value="#{bean.date}"
>>                                   label="Select a date, but check possible
>> holidays first">
>>                 <tr:convertDateTime pattern="yyyy-MM-dd"/>
>>                 <tr:validateDateRestriction
>> invalidDays="#{bean.date.nationalHolidays}" />
>>               </tr:inputDate>
>>
>

Re: how to restrict inputDate to be the 1st date of each month within a range of date

Posted by Jakob Korherr <ja...@gmail.com>.
Hi,

Why do you want to select only the 1st day of each month? do you want to
select a month with this component? If so, why don't you just use two
<h:selectOneMenu> components, one for the month and one for the year?

Regards,

Jakob Korherr

2009/12/18 <lw...@att.net>

>  Hi,
>  with the following code, I don't think it suits my need.  Please advise if
> there is way to achieve only allowing 1st day of each month within a certain
> range, say within Oct 15, 2008 - Oct 30, 2010 to be selectable.  If this is
> not possible, backend validation is the only choice.
>
>  <tr:inputDate id="days" value="#{bean.date}"
>                                   label="Select a date, but check possible
> holidays first">
>                 <tr:convertDateTime pattern="yyyy-MM-dd"/>
>                 <tr:validateDateRestriction
> invalidDays="#{bean.date.nationalHolidays}" />
>               </tr:inputDate>
>

Re: how to restrict inputDate to be the 1st date of each month within a range of date

Posted by Richard Yee <ri...@gmail.com>.
I'm not sure that adding a validDays attribute is a very workable
solution. What happens if there is an overlap with the valid and
invalid days? Right now, the same thing could be accomplished by
putting all of the dates in the date range in the invalidDays list and
removing the first day of the month.

I haven't used the validateDateRestriction tag personally, but unless
it prevents the user from selecting the dates in the invalidDates
list, you probably shouldn't use it for use case because it would be a
bad UI design to allow the user to select a date that is invalid.

If you want to make an enhancement request to the component, you
should file a Jira issue. Suggestions on an email list will most
likely be ignored.

-Richard


On Tue, Dec 22, 2009 at 11:30 AM,  <lw...@att.net> wrote:
> That sounds good.
>
> Also May be we can suggest trinidad to have another attribute called
> "validDays" for the tr:validateDateRestriction component like the following:
>
>  <tr:inputDate id="days" value="#{bean.date}"
>                                   label="Select a date">
> <tr:convertDateTime pattern="yyyy-MM-dd"/>
> <tr:validateDateRestriction  validDays="#{bean.date.allowableDates}" />
> </tr:inputDate>
>
> -------------- Original message from Richard Yee <ry...@cruzio.com>:
> --------------
>
>
>> If you are going to limit the date selection to the first day of the
>> month within a date range, you are probably better off just to use a
>> selectOneChoice with a selectItem for each month that is within the date
>> range. The inputDate does not provide much benefit here since there is
>> only one date per month that can be chosen.
>>
>> -Richard
>>
>> lwu1@att.net wrote:
>> > Hi,
>> > with the following code, I don't think it suits my need. Please
>> > advise if there is way to achieve only allowing 1st day of each month
>> > within a certain range, say within Oct 15, 2008 - Oct 30, 2010 to be
>> > selectable. If this is not possible, backend validation is the only
>> > choice.
>> >
>> > > > label="Select a date, but check
>> > possible holidays first">
>> >
>> > > > invalidDays="#{bean.date.nationalHolidays}" />
>> >
>>

Re: how to restrict inputDate to be the 1st date of each month within a range of date

Posted by lw...@att.net.
That sounds good. 

Also May be we can suggest trinidad to have another attribute called "validDays" for the tr:validateDateRestriction component like the following:

 <tr:inputDate id="days" value="#{bean.date}"
                                  label="Select a date">
<tr:convertDateTime pattern="yyyy-MM-dd"/>
<tr:validateDateRestriction  validDays="#{bean.date.allowableDates}" />
</tr:inputDate>


-------------- Original message from Richard Yee <ry...@cruzio.com>: -------------- 


> If you are going to limit the date selection to the first day of the 
> month within a date range, you are probably better off just to use a 
> selectOneChoice with a selectItem for each month that is within the date 
> range. The inputDate does not provide much benefit here since there is 
> only one date per month that can be chosen. 
> 
> -Richard 
> 
> lwu1@att.net wrote: 
> > Hi, 
> > with the following code, I don't think it suits my need. Please 
> > advise if there is way to achieve only allowing 1st day of each month 
> > within a certain range, say within Oct 15, 2008 - Oct 30, 2010 to be 
> > selectable. If this is not possible, backend validation is the only 
> > choice. 
> > 
> > > > label="Select a date, but check 
> > possible holidays first"> 
> > 
> > > > invalidDays="#{bean.date.nationalHolidays}" /> 
> > 
> 

Re: how to restrict inputDate to be the 1st date of each month within a range of date

Posted by Richard Yee <ry...@cruzio.com>.
If you are going to limit the date selection to the first day of the 
month within a date range, you are probably better off just to use a 
selectOneChoice with a selectItem for each month that is within the date 
range. The inputDate does not provide much benefit here since there is 
only one date per month that can be chosen.

-Richard

lwu1@att.net wrote:
> Hi,
>  with the following code, I don't think it suits my need.  Please 
> advise if there is way to achieve only allowing 1st day of each month 
> within a certain range, say within Oct 15, 2008 - Oct 30, 2010 to be 
> selectable.  If this is not possible, backend validation is the only 
> choice.
>  
>  <tr:inputDate id="days" value="#{bean.date}"
>                                   label="Select a date, but check 
> possible holidays first">
>                 <tr:convertDateTime pattern="yyyy-MM-dd"/>
>                 <tr:validateDateRestriction  
> invalidDays="#{bean.date.nationalHolidays}" />
>               </tr:inputDate>