on 08-19-2010 12:21 PM
Hi all,
I have a requirement of enabling a button according to system time ie from 9:00 am to 10:00 am I need to have the button functionality disabled for particular days. Is this type of functionality possible if so can anyone help me in how I can go about with it.
Thank you
Regards,
Preet
Hello Preet,
you can use the following code :-
this particular piece of code will enable the button for monday to friday and morning 9 am to evening 5 pm.
you need to write this code in wddoinit of your view and also bind the enable property of your button to one boolean attribute in context. for example here i have bound it to btnpro.
java.util.Calendar cl = Calendar.getInstance(); // get the current time and date
int day = cl.get(cl.DAY_OF_WEEK);
int hour = cl.get(cl.HOUR_OF_DAY);
if((day >= 1 || day <= 5 )&&((hour >= 9 && hour <= 17)))
{
wdContext.currentContextElement().setBtnpro(true);
}
else
{
wdContext.currentContextElement().setBtnpro(false);
}
Thanks
Sarbjeet Singh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Preet,
Yes, this will be possible but you need to play with calander, date methods to achive your requierment.
Then once you accomplish your requirement, try to enable/disable button based on the conditions.
Regards
Arun Jaiswal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try using the following code to get the time:
java.sql.Date dateValue = new Date(System.currentTimeMillis());
java.sqlTime timeValue = new Time(dateValue.getTime());
int finalValue = 24 - timeValue.getHours();
if(finalValue == 15)
{
//Set the button enabled property to false;
}
else
{
//Set the button enabled property to true;
}
Hope this helps you.
Regards,
Poojith MV
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.