Here is how it works:
- Make sure, the XPage has set
dojoParseOnLoad="true" dojoTheme="true"
either in xp:view tag or in "All Properties" tab - Make sure you have added the following line to your ressources:
<xp:dojoModule name="dijit.form.TimeTextBox"></xp:dojoModule>
- Drag a Date/Time control on your page
- Make it "Time" only
- Make sure "Use date/time picker pop-up is checked
- Mark it and switch to source tab.
- Add
dojoType="dijit.form.TimeTextBox"
to the xp:dateTimeHelper tag - When you click into the tag xp:dateTimeHelper, you now get a dojo sections in the "All properties" tab (you can type it in by hand too).
- Now you can add dojoAttributes like these, and make them computed too:
- displayedValue: compute a value to be displayed on startup - or just get the value from the document to be displayed
- onchange: execute some client-side java script
- constraints: define the properties of this dijit control to show e.g. clickable fields every half an hour instead of every 5 minutes.
- every other property you need. Consult dojo documentation at:
http://www.dojotoolkit.org/api/dijit/form/TimeTextBox.html
Here is the complete source code for such an XPage:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xc="http://www.ibm.com/xsp/custom"
dojoParseOnLoad="true"
dojoTheme="true">
<xp:this.resources>
<xp:dojoModule name="dijit.form.TimeTextBox"></xp:dojoModule>
<xp:dojoModule name="dijit.form.DateTextBox"></xp:dojoModule>
</xp:this.resources>
<xp:inputText value="#{documentTask.EndTime}"
id="endTime1" required="true" style="width:5em"
styleClass="lotusText" tabindex="5" defaultValue="17:30">
<xp:this.converter>
<xp:convertDateTime type="time"
timeStyle="short">
</xp:convertDateTime>
</xp:this.converter>
<xp:dateTimeHelper
dojoType="dijit.form.TimeTextBox" id="dateTimeHelperEndTime">
<xp:this.dojoAttributes>
<xp:dojoAttribute
name="displayedValue">
<xp:this.value><![CDATA[#{javascript:getComponent('endTime1')?getComponent('endTime1').value:'17:30';}]]></xp:this.value>
</xp:dojoAttribute>
<xp:dojoAttribute name="constraints"
value="{timePattern: 'HH:mm', clickableIncrement: 'T00:30:00', visibleIncrement: 'T00:30:00',visibleRange: 'T05:00:00'}">
</xp:dojoAttribute>
</xp:this.dojoAttributes>
</xp:dateTimeHelper>
</xp:inputText>
</xp:view>
No comments:
Post a Comment