I'm trying to use SSJS to update a date field. This works fine if the option "Use date/time picker pop-up" is not selected. However if this option is checked, the update does not work. Can anyone explain why this is? Here is my code:
<xp:panel rendered="true">
<xp:button value="Set Date Value" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="DateField">
<xp:this.action><![CDATA[#{javascript:document1.setValue("DateField","01.01.1970");}]]></xp:this.action>
</xp:eventHandler></xp:button>
<xp:inputText id="DateField" value="#{document1.DateField}">
<xp:this.converter>
<xp:convertDateTime type="date"></xp:convertDateTime>
</xp:this.converter>
<xp:dateTimeHelper></xp:dateTimeHelper>
</xp:inputText>
</xp:panel>
To be able to set a date field you need to set it using a correct date format
document1.setValue("DateField","01.01.1970")
The Date format needs to be java.util.Date so try this
document1.setValue("DateField",new Date("01.01.1970"))
But I would suggest doing it this way because then you code isn't bound to that the server is using that specific locale settings.
var date=new Date();
date.setFullYear(1970)
date.setMonth(0) //remember months starts with 0
date.setDate(1)
document1.setValue("DateField",date)
One thing is that I haven't got this to work when running in a Notes client, but that might be a bug.
Related
I have dynamic view control that is used to display several views from a database. I allow users to filter this view using input that is bound to a viewscope variable that is used in keys attribute of Domino View.
It works just fine, but some views have sortable column that strangely. Problem is that when users resorts the view and then tries to filter, the sort order is lost.
I also tried call setKeys programmatically on datasource, but with same results. Also setting setResortOrder on the dataModel has no effect. Sort order seems to be lost when different key value is set.
To get correct result, users have to resort the view again after submitting the sort.
(on Domino 9.0.1 with v11 ExtLib)
update - code snippet for basic scenario
<xp:panel id="content">
<xp:inputText id="searchInput" value="#{viewScope.tmpSearchText}" />
<xp:button id="search">
Search
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="content">
<xp:this.action><![CDATA[#{javascript:viewScope.searchText=viewScope.tmpSearchText;}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xe:dynamicViewPanel id="viewPanel">
<xe:this.data>
<xp:dominoView var="view1" keys="#{viewScope.searchText}"
viewName="DleCislaW" >
</xp:dominoView>
</xe:this.data>
</xe:dynamicViewPanel>
</xp:panel>
I hope you guys are doing good. I am using date and time control on front end for selection of Time from date and time control and only time is visible at front end. My users are using different timezone.
(UTC +09) Osaka, Singapore, Tokyo
(UTC +05) Tashkant
Now data stored in time field is different in binding field. How can I override field data using SSJS to keep all users in single timezone.
e.g. i want to using UTC +05 for all users having different zones.
Kindly let me know if you require any clarification about my question.
Thanks,
Qaiser
According to this info you can automaticaly convert date/time field to specific time zone natively.
Try this example:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.data>
<xp:dominoDocument
var="document1"
formName="FRM">
</xp:dominoDocument>
</xp:this.data>
<xp:label
value="UTC Tashkent:"
id="label1"
for="computedField1">
</xp:label>
<xp:inputText
id="inputText1"
value="#{document1.utc5}"
defaultValue="#{javascript:#Now()}">
<xp:this.converter>
<xp:convertDateTime
timeZone="Asia/Tashkent"
type="time"></xp:convertDateTime>
</xp:this.converter>
<xp:dateTimeHelper></xp:dateTimeHelper>
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete">
</xp:eventHandler>
</xp:inputText>
Your UTC: <xp:text
escape="true"
id="computedField1"
value="#{document1.utc5}">
<xp:this.converter>
<xp:convertDateTime
type="time"></xp:convertDateTime>
</xp:this.converter>
</xp:text>
<xp:br></xp:br>
<xp:button
value="Save"
id="button1">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete">
<xp:this.action>
<xp:saveDocument
var="document1"></xp:saveDocument>
</xp:this.action>
</xp:eventHandler>
</xp:button>
</xp:view>
The page forces edit box to be shown in Tashkent time zone, regardless of browser's settings. Be aware, that stored value may be different, if server's time zone is different from the forced one.
This is a continuation of a previous question that I asked last week.
I have an XPage. On this XPage I have a repeater. In this repeater, I have a custom control that I am using to display the contents of its own datasource - a NotesXspDocument. This control is repeated 5 to 10 times, maybe up to 15 times. I do not want to make the user press on save for each and every repeated control, so I am using the submit button feature as described in the above linked question.
When the user presses the submit button, I am using the querySaveDocument and the postSaveDocument actions on the events tab (I also tried the properties with the same name in the Data tab with the same result). My issue is the following:
The validation is executed one control instance after another until the validation fails immediately saving the datasource before moving on to the next instance. When a NEW document is saved, it seems like the XspDocument is gone and the fields are emptied. I have checked, and I have set the datasource scope to view, as this behavior somehow resembles requestScope. As soon as I reload the page, the information is correctly presented.
I could use "context.reloadPage()" to just get the updated information, but this has the nasty side effect of removing all unsaved information (for example if validation failed on the xth line). How might I best go about solving/troubleshooting this issue? What should I be paying attention to? Has anyone else seen such a behavior?
I would love to call a validate function on all rows from the Containing XPage and then if all rows succeeded, then call the saveDataSources function. Any help is greatly appreciated!
A simple button outside your repeat control will do. I created this example:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:repeat id="repeat1" rows="30" value="#{javascript:4}">
<xp:panel id="dataPanel" disableOutputTag="true">
<xp:this.data>
<xp:dominoDocument var="document1" formName="Demo2">
</xp:dominoDocument>
</xp:this.data>
<xp:table>
<xp:tr>
<xp:td>
<xp:label value="Subject!" id="subject_Label1" for="subject1">
</xp:label>
</xp:td>
<xp:td>
<xp:inputText value="#{document1.Subject}"
id="subject1" required="true">
<xp:this.validators>
<xp:validateRequired
message="Say something">
</xp:validateRequired>
<xp:validateLength minimum="5"
message="Say 5 characters or more">
</xp:validateLength>
</xp:this.validators>
</xp:inputText>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:label value="Color!" id="color_Label1" for="color1">
</xp:label>
</xp:td>
<xp:td>
<xp:comboBox value="#{document1.Color}"
id="color1" defaultValue="red">
<xp:this.validators>
<xp:validateExpression
message="We don't like red">
<xp:this.expression><![CDATA[#{javascript:value != "red"}]]></xp:this.expression>
</xp:validateExpression>
</xp:this.validators>
<xp:selectItem itemLabel="red"></xp:selectItem>
<xp:selectItem itemLabel="yellow"></xp:selectItem>
<xp:selectItem itemLabel="green"></xp:selectItem>
<xp:selectItem itemLabel="blue"></xp:selectItem>
<xp:selectItem itemLabel="white"></xp:selectItem>
<xp:selectItem itemLabel="black"></xp:selectItem>
</xp:comboBox>
</xp:td>
</xp:tr>
</xp:table>
</xp:panel>
</xp:repeat>
<xp:messages layout="table" style="color:red" id="messages1">
</xp:messages>
<xp:button value="Save?" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete" immediate="false" save="true"></xp:eventHandler>
</xp:button>
</xp:view>
It will not save any of the data unless all validations are satisfied and it will not remove any entered data either. Don't get into the way what XPages does automatically (you also don't brush a cat against her fur). Your validation should happen in the validator and let the data source be saved by the button. As you see: no Query/Post event code is needed here.
I really don't get what you're trying to do so I'll just comment on a piece.
If you want data to survive a context.reloadPage() I think you would need to bind your controls to sessionScope. ViewScope is probably wiped out during the reload but sessionScope should still be available.
Good Luck!
I'm working on an XPage for mobile users for an existing application. I want to use the mobile controls from the ExtLib for this.
I've build an XPage with a SinglePageApp and some AppPages on it. Now I want to build an AppPage with a search menu, a simple inputText and a button to start the search.
The inputText is bind to a sessionScope variable. I want to use the variable in a second appPage to get the search value and show a filtered/searched view.
The problem is the button. I'm not sure how to build this button to move to the other appPage. This is my last attempt, which fails with a runtime error.
Any idea how to get this running or what's wrong ?
Kind regards
Ingo
<xe:appPage id="appPage34" pageName="searchPage" preload="true" resetContent="true">
<xe:djxmHeading id="djxmHeading34" label="Search..." back="Home" moveTo="home">
</xe:djxmHeading>
<xp:inputText id="searchInput" value="#{sessionScope.searchValue}">
</xp:inputText>
<xp:button value="Search" id="button1" refreshMode="complete" type="submit">
<xp:eventHandler event="onclick" submit="true">
<xp:this.action>
<xe:moveTo targetPage="#searchResult"></xe:moveTo>
</xp:this.action>
</xp:eventHandler>
</xp:button>
</xe:appPage>
What does the runtime error say?
If you can not get to the XPages log files on the server directly, then use XPages Log File Reader from OpenNTF to get easy access to the log files from a browser.
Does it work if you use "searchResult" as the value for targetPage (assuming the appPage is called "searchResult")?
I've now come to a solution with a static line item instead of a button, since I couldn't get the button working. I think it has something to do with the way the single page application handles the access to mobile pages.
The search page looks like this :
<xe:appPage id="appPage34" pageName="searchPage" preload="true" resetContent="true">
<xe:djxmHeading id="djxmHeading34" label="Search..." back="Home" moveTo="home">
</xe:djxmHeading>
<xp:inputText id="searchInput" value="#{sessionScope.searchValue}">
<xp:eventHandler event="onblur" submit="true" refreshMode="complete">
<xp:this.action>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:var svalue = getComponent("searchInput").getValue(); sessionScope.put("searchValue",svalue);}]]></xp:this.script>
</xp:executeScript>
</xp:this.action>
</xp:eventHandler>
</xp:inputText>
<xp:br></xp:br>
<xp:br></xp:br>
<xe:djxmLineItem id="djxmLineItem41" label="Start Search..." moveTo="#searchResult">
</xe:djxmLineItem>
</xe:appPage>
In the mobile page for showing the search result I simply get the value of the sessionScope variable, issue a full text search with the value and use the resulting document collection in a repeat control.
I still would rather use a button because the static line item is not really what a user expects as a gui element to start the search. But at least this is working.
I have a check box that is disabled. I click a button that sets the value of that check box to be 'checked'. When I go to save, the check box loses its value. Anyone have any ideas? Here is a simple mockup:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.data>
<xp:dominoDocument
var="MainForm"
formName="MainForm" />
</xp:this.data>
<xp:checkBox
text="CheckBox"
id="CheckBox"
value="#{MainForm.CheckBox}"
disabled="true"
checkedValue="Y"
uncheckedValue="N">
</xp:checkBox>
<xp:br></xp:br>
<xp:button
id="setBc"
value="Set CheckBox">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="partial"
refreshId="CheckBox">
<xp:this.action><![CDATA[#{javascript:getComponent("CheckBox").setValue("Y");}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button
value="Save"
id="button5">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:MainForm.save();}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
</xp:view>
Disabled controls are not included in page submissions.
You can combine your disabled check box with a xp:inputHidden control which is a hidden input field that is included in page submissions.
This could be a specific problem to Domino 8.5.3 (if that is what you are using).
We have noticed that since we upgraded to 8.5.3 we get a problem (on normal classic domino pages) where fields tagged as "disabled" don't get saved down to the doc.
We have had to build around this by not using a "proper" field that is disabled for values that has to later be saved.
Another workaround was to remove the disabled setting before posting in the post script.
We are fairly sure this all started to happened with the release of 8.5.3