user1358852
user1358852

Reputation:

XPages - modify display of Dojo Time Text box

I'm using a Dojo Time Text Box on my XPage. When I save a time in this field, the displayed time has a "T" prefix. Is there any way of removing this "T"? Here is my code:

<xp:inputText id="EventEndTime" value="#{document1.EventEndTime}"         style="width:160px;"
role="button" title="used to pick a meeting time" required="true"
dojoType="dijit.form.TimeTextBox"
disableClientSideValidation="true">
<xp:this.dojoAttributes>
<xp:dojoAttribute    name="required"  value="false">
</xp:dojoAttribute>                           
</xp:this.dojoAttributes>                                
</xp:inputText>                                                                                                       

Upvotes: 1

Views: 535

Answers (2)

stwissel
stwissel

Reputation: 20384

Domino doesn't actually store "Time only", so you would want to use a viewScope variable to bind to your TimeTextBox first and use the load and save events to write to / read from that. I would use the SimpleDateFormat class for conversion which is way more comfortable that manual string operations. Actually a small Java helper class works wonders here.

Alternatively you could use a filter to clean this up.

Upvotes: 3

Knut Herrmann
Knut Herrmann

Reputation: 30960

You can add a custom converter to your inputText control which deletes the "T" before saving and adds "T" during rendering page:

<xp:this.converter>
    <xp:customConverter>
        <xp:this.getAsObject><![CDATA[#{javascript:value.substring(1)}]]></xp:this.getAsObject>
        <xp:this.getAsString><![CDATA[#{javascript:"T" + value}]]></xp:this.getAsString>
    </xp:customConverter>
</xp:this.converter>

This way time gets saved as string like "hh:mm:ss" instead of "Thh:mm:ss".

You could use a custom converter to save value as a Notes time value also.

Upvotes: 3

Related Questions