-
1. Re: Update backing bean from rich:calendar?
lanceb185 May 21, 2008 11:50 AM (in response to lanceb185)Ok, managed to solve this myself. For the record, used
<a4j:support event="ondateselected" ajaxSingle="true"/>
- Lance -
2. Re: Update backing bean from rich:calendar?
ilya_shaikovsky May 21, 2008 12:06 PM (in response to lanceb185)It will be even better if you will use onchanged event. Then the date will be stored after any change.. Using ondateselected - it will not be stored after time change for example.
-
3. Re: Update backing bean from rich:calendar?
aish Jun 20, 2008 5:44 PM (in response to lanceb185)Hi,
Can you please post your backing bean code as I have a similar situation to take the date value to the backing bean. I tried your below code as it is and does not work for me.
Your help is greatly appreciated
Thanks
Aish -
4. Re: Update backing bean from rich:calendar?
lanceb185 Jun 21, 2008 6:01 AM (in response to lanceb185)Hi Aish
Ok, the JSF looks like this:<rich:calendar id="cal" value="#{bean.date}" popup="true" datePattern="#{bean.pattern}" showApplyButton="false" style="width:200px" disabled='#{bean.selected == true}'> <a4j:support ajaxSingle="true" event="ondateselected"/> </rich:calendar>
And the Java like this:package com.test; import java.util.Date; public final class Bean { private Date date = new Date(System.currentTimeMillis()); private boolean selected = false; private String pattern = "dd-MMM-yyyy"; public Bean() { } public Date getDate() { return date; } public void setDate(Date date) { this.date = date; System.out.println("Bean.setDate: " + date); } public boolean isSelected() { return selected; } public void setSelected(boolean selected) { this.selected = selected; } }
If this doesn't work, check that your bean is correctly declared in faces-config.xml like this:<managed-bean> <managed-bean-name>bean</managed-bean-name> <managed-bean-class>com.test.Bean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean>
hth,
Lance -
5. Re: Update backing bean from rich:calendar?
hassane Jun 24, 2008 10:33 AM (in response to lanceb185)"ilya_shaikovsky" wrote:
It will be even better if you will use <b>onchanged</b> event. Then the date will be stored after any change.. Using ondateselected - it will not be stored after time change for example.
+1
if you use the ondateselected event, you gonna get the precedent date chosen, not the current one, for example you clicked on 06/24 this date will be passed to the server just after you choose another date. -
6. Re: Update backing bean from rich:calendar?
aish Jun 26, 2008 5:55 PM (in response to lanceb185)Hi,
The date selection from <rich:calendar> works fine. I have two date fields - from date and to date. I would like to add a validation saying "From Date cannot be greater than To date" and "To Date cannot be less than From Date". <a4j:support> has a event but that is used to update backing bean ondateselected. Can we have multiple events? If not, how do we accomplish the date validation?
Your answer would be very hepful
Thanks
Aish -
7. Re: Update backing bean from rich:calendar?
ilya_shaikovsky Jun 28, 2008 8:29 AM (in response to lanceb185)you could define request for multiple events using multiple supports inside ;)
-
8. Re: Update backing bean from rich:calendar?
aish Jul 1, 2008 4:44 PM (in response to lanceb185)Hi Ilya,
Thanks for your response. Everything worked fine. All of a sudden I started getting a runtime error . It says "Runtime error has occured" Error OldJquery is undefined. Can you please let me know why it is happening? When I tried to debug, It is pointing to the first sentence given below:
Can you please let me know.. I have also posted this as a separate post also. It is very painful to skip this message for every click on the screen.. I have been trying for the entire day and it is happening only in the calendar.
Thanks
Aish
var sbjQuery=oldJQuery;sbjQuery.fn.SpinButton=function(cfg){return this.each(function(){this.spinCfg={min:cfg&&!isNaN(parseFloat(cfg.min))?Number(cfg.min):null,max:cfg&&!isNaN(parseFloat(cfg.max))?Number(cfg.max):null,step:cfg&&cfg.step?Number(cfg.step):1,page:cfg&&cfg.page?Number(cfg.page):10,upClass:cfg&&cfg.upClass?cfg.upClass:'up',downClass:cfg&&cfg.downClass?cfg.downClass:'down',reset:cfg&&cfg.reset?cfg.reset:this.value,delay:cfg&&cfg.delay?Number(cfg.delay):500,interval:cfg&&cfg.interval?Number(cfg.interval):100,_btn_width:20,_btn_height:12,_direction:null,_delay:null,_repeat:null,digits:cfg&&cfg.digits?Number(cfg.digits):1};this.adjustValue=function(i){var v=this.value.toLowerCase();if(v=="am")
{this.value="PM";return;}
else if(v=="pm"){this.value="AM";return;}
v=(isNaN(this.value)?this.spinCfg.reset:Number(this.value))+Number(i);if(this.spinCfg.min!==null)v=(v<this.spinCfg.min?(this.spinCfg.max!=null?this.spinCfg.max:this.spinCfg.min):v);if(this.spinCfg.max!==null)v=(v>this.spinCfg.max?(this.spinCfg.min!=null?this.spinCfg.min:this.spinCfg.max):v);var value=String(v);while(value.length<this.spinCfg.digits)value="0"+value;this.value=value;};sbjQuery(this).keydown(function(e){switch(e.keyCode){case 38:this.adjustValue(this.spinCfg.step);break;case 40:this.adjustValue(-this.spinCfg.step);break;case 33:this.adjustValue(this.spinCfg.page);break;case 34:this.adjustValue(-this.spinCfg.page);break;}}).bind("mousewheel",function(e){if(e.wheelDelta>=120)
this.adjustValue(this.spinCfg.step);else if(e.wheelDelta<=-120)
this.adjustValue(-this.spinCfg.step);e.preventDefault();}).change(function(e){this.adjustValue(0);});var self=this;var btnUp=$(this.id+'BtnUp');sbjQuery(btnUp).mousedown(function(e){var adjust=function(){self.adjustValue(self.spinCfg.step);};adjust();self.spinCfg._delay=window.setTimeout(function(){adjust();self.spinCfg._repeat=window.setInterval(adjust,self.spinCfg.interval);},self.spinCfg.delay);self.spinCfg._repeater=true;}).mouseup(function(e){self.spinCfg._repeater=false;window.clearInterval(self.spinCfg._repeat);window.clearTimeout(self.spinCfg._delay);}).dblclick(function(e){if(sbjQuery.browser.msie)
self.adjustValue(self.spinCfg.step);}).mouseout(function(e){if(self.spinCfg._repeater)
{self.spinCfg._repeater=false
window.clearInterval(self.spinCfg._repeat);window.clearTimeout(self.spinCfg._delay);}});var btnDown=$(this.id+'BtnDown');sbjQuery(btnDown).mousedown(function(e){var adjust=function(){self.adjustValue(-self.spinCfg.step);};adjust();self.spinCfg._delay=window.setTimeout(function(){adjust();self.spinCfg._repeat=window.setInterval(adjust,self.spinCfg.interval);},self.spinCfg.delay);self.spinCfg._repeater=true;}).mouseup(function(e){self.spinCfg._repeater=false;window.clearInterval(self.spinCfg._repeat);window.clearTimeout(self.spinCfg._delay);}).dblclick(function(e){if(sbjQuery.browser.msie)
self.adjustValue(-self.spinCfg.step);}).mouseout(function(e){if(self.spinCfg._repeater)
{self.spinCfg._repeater=false
window.clearInterval(self.spinCfg._repeat);window.clearTimeout(self.spinCfg._delay);}});if(this.addEventListener){this.addEventListener('DOMMouseScroll',function(e){if(e.detail>0)
this.adjustValue(-this.spinCfg.step);else if(e.detail<0)
this.adjustValue(this.spinCfg.step);e.preventDefault();},false);}});function coord(el,prop){var c=el[prop],b=document.body;while((el=el.offsetParent)&&(el!=b)){if(!sbjQuery.browser.msie||(el.currentStyle.position!='relative'))
c+=el[prop];}
return c;}}