<?xml version="1.0" encoding="UTF-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core"> <xp:br></xp:br> 西暦: <xp:inputText id="inputText1"> <xp:dateTimeHelper id="dateTimeHelper1"></xp:dateTimeHelper> <xp:this.converter> <xp:convertDateTime type="date"></xp:convertDateTime> </xp:this.converter> <xp:eventHandler event="onchange" submit="true" refreshMode="complete"> </xp:eventHandler> <xp:eventHandler event="onclick" submit="true" refreshMode="complete"> </xp:eventHandler></xp:inputText> <xp:br></xp:br> <xp:br></xp:br>和暦: <xp:text escape="true" id="computedField1"> <xp:this.converter> <xp:convertDateTime type="date" locale="ja_JP_JP"></xp:convertDateTime> </xp:this.converter> <xp:this.value><![CDATA[#{javascript:getComponent("inputText1").getValue();}]]></xp:this.value></xp:text> <xp:br></xp:br> <xp:br></xp:br> 年齢: <xp:text escape="true" id="computedField2"><xp:this.value><![CDATA[#{javascript:var selectDate = getComponent("inputText1").getValue(); var nenrei = -1; if(selectDate==null){ return ""; }else{ var todayDate = @Today(); nenrei = @Year(todayDate) - @Year(selectDate); var tmpMonth = @Month(todayDate) - @Month(selectDate); if( tmpMonth < 0 || (tmpMonth == 0 && @Day(todayDate) < @Day(selectDate))){ nenrei = nenrei - 1; } } return @Text(@Integer(nenrei));}]]></xp:this.value></xp:text>歳</xp:view>