Aug 23, 2016 11:39 AM
94 Posts

My date field format changes automatically upon file upload / refresh. How can I fix that?

  • Category: Debugging
  • Platform: Windows
  • Release: 9.0.1
  • Role: Developer
  • Tags:
  • Replies: 2

I have a panel with a date field and an upload control.  The Date field is formatted as MMM d, yyyy.  When I pick a date, it displays correctly.  However, upon selecting a file in the upload control, the date field automatically changes to yyyy-mm-dd format and the date picker button disappears and I get an "invalid date" error.  The upload is causing the issue.

If I manually change the date again to it's intended format, I can refresh the panel (which retrieves the date picker button again) and am able to save the document.

If I select a date and manually refresh the panel, the date format will not change.  It only auto changes when a file is selected in the upload control.

I originally had the date format using "Default" but have since changed it to "Custom" for MMM d, yyyy format, but there was no change, it still reformats automatically with a file selection.

How do I get around this problem?

Aug 25, 2016 12:38 AM
453 Posts
Would need to see the source code.

Can you create a simple page with the date field and upload control and see if you can make it do the same thing. I'm guessing but I would think that there might be something elsewhere on the page that is getting in the way.  I had something similar the other day and I eventually stripped the page down and isolated the problem then rebuilt the functional page. The solution in my case was pretty simple. I have an axiom 'a bug that is easy to find is hard to fix, a bug that is hard to find is easy to fix---- all bugs take the same time to fix!

Aug 25, 2016 9:33 AM
94 Posts
Thank you for the input

Yes, I had to do exactly that, stripped everything out except the date, the upload and a Save button.  I discovered that the document would actually save, and THEN the date would get reformatted.  So, as a workaround, I added code to clear the date field in the oncomplete event of the Save button - and that actually works.  So, not a solution, but a workaround.  (I was able to do that only because the Save performed a partial refresh.  The form actually appears in a dojo dialog panel)

I'm still looking for a solution, because I'm afraid I'll run into this again in the future.

Here's how it looks before Save

and after Save

Here's the xpage code

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"><xp:panel id="panelCustPO">
        <xp:this.data>
            <xp:dominoDocument var="document3" formName="CustPOTemp" ignoreRequestParams="true">
            </xp:dominoDocument>
        </xp:this.data>
        
        <xp:table style="background-color:rgb(242,242,242);border-color:rgb(128,128,128);border-style:solid;border-width:thin">
            
            <xp:tr>
                <xp:td style="text-align:right">

                    <xp:label value="P.O. Received Date:" id="label101">
                    </xp:label>
                </xp:td>
                <xp:td style="background-color:rgb(255,255,255)">
                    <xp:inputText id="DateRec" value="#{document3.DateRec}" style="height:20px">
                        <xp:this.converter>
                            <xp:convertDateTime pattern="MMM d, yyyy">
                            </xp:convertDateTime>
                        </xp:this.converter>
                        <xp:dateTimeHelper></xp:dateTimeHelper>
                    </xp:inputText>
                    
                </xp:td>
                <xp:td></xp:td>
            </xp:tr>
            <xp:tr>
                <xp:td style="text-align:right" valign="top">
                    <xp:label value="P.O. Attachment:" id="label225"
                        style="font-size:9pt">
                    </xp:label>
                </xp:td>
                <xp:td style="background-color:rgb(255,255,255)">
                    <xp:fileUpload id="Attachments"
                        value="#{document3.Attachments}" style="width:99%;height:20px">
                    </xp:fileUpload>
                </xp:td>
                <xp:td></xp:td>
            </xp:tr>
            <xp:tr>
                <xp:td colspan="3" style="background-color:rgb(255,255,255);text-align:right;padding-top:10.0px">
                    <xp:button id="button18" value="OK" style="width:80px;margin-bottom:5.0px">
                        <xp:eventHandler event="onclick" submit="true"
                            refreshMode="partial" id="eventHandler55"
                            refreshId="panelCustPO">
                            <xp:this.action>
                                <xp:actionGroup>
                                    <xp:saveDocument var="document3"></xp:saveDocument>
                                    <xp:confirm
                                        message="save successful">
                                    </xp:confirm>
                                </xp:actionGroup>
                            </xp:this.action>
                            <xp:this.onComplete><![CDATA[//var fld = XSP.getElementById("#{id:DateRec}");
//fld.value = ""]]></xp:this.onComplete>
                        </xp:eventHandler>
                    </xp:button>
                </xp:td>
            </xp:tr>
        </xp:table>
    </xp:panel>
</xp:view>