Setting value of a djDateTextBox and djTimeTextBox? - xpages

How do I set the value of a djDateTextBox and djTimeTextBox component?
I tried
getComponent("djDateTextBox1").setValue("10/12/2012");
but that does not seem to work.

for me, this code here works just fine (is called by a button's server side onclick event, performing a full update):
getComponent("djDateTextBox1").setValue(#Today());
Otherwise you also could achieve a similar result using some client side script as in
dojo.byId("#{id:djDateTextBox1}").value = new Date();

Thanks to Lothar for putting me on the right track but this is how I solved it:
var sdt:NotesDateTime = doc.getItemValueDateTimeArray("ContractorStartDateTime")[0];
var fdt:NotesDateTime = doc.getItemValueDateTimeArray("ContractorFinishDateTime")[0];
getComponent("djDateTextBox1").setValue(sdt.toJavaDate());
getComponent("djTimeTextBox1").setValue(sdt.toJavaDate());
getComponent("djDateTextBox2").setValue(fdt.toJavaDate());
getComponent("djTimeTextBox2").setValue(fdt.toJavaDate());

Related

#material material-component-web Invalid tab component given as activeTab

firstly let my say that the mdc documentation is difficult for non-pros like me.
I'm using Elixir Phoenix and Brunch.
I import and everything is fine.
import {MDCTab, MDCTabFoundation} from '#material/tabs'; import
{MDCTabBar, MDCTabBarFoundation} from '#material/tabs'; import
{MDCTabBarScroller, MDCTabBarScrollerFoundation} from
'#material/tabs';
I manually instantiate the tab bar in a separate function that I export
export var Tabbable = {
run: function(MDCTabBar, el){
var myDynamicTabBar = window.myDynamicTabBar = new MDCTabBar(document.querySelector('#' + el));
Which is following the documentation like this
const tabBar = new MDCTabBar(document.querySelector('#my-mdc-tab-bar'));
but is slightly different to the documentation's use of the tab bar in their code snippet
var dynamicTabBar = window.dynamicTabBar = new mdc.tabs.MDCTabBar(document.querySelector('#dynamic-tab-bar'));
But, whenever I try to use mdc I get a 'not defined' error. Therefore, I'm not using it :-)
Now, when the user clicks the tab bar I capture that like this:
myDynamicTabBar.listen('MDCTabBar:change', function ({detail: tabs}) {
var nthChildIndex = tabs.activeTabIndex;
updatePanel(nthChildIndex);
});
The subtle difference is that my myDynamicTabBar is MDCTabBar but the documentation's dynamicTabBar is mdc.tabs.MDCTabBar
My tab control works, but it throws an error only visible in the console:
Uncaught Error: Invalid tab component given as activeTab: Tab not
found within this component's tab list
which is likely because I'm not using mdc.tabs? The documentation notes the change event happens on the MDCTabBar.
Therefore, how do I get rid of this annoying error in the console?
And why can I not access the global mdc? I have tried this in my Brunch file
globals: { mdc: "#material"}
But no good.
I'm right behind you on this! I'm frustrated with the docs too :(
You answered your own question in this Elixir thread which is very informative.
I found the real solution in this thread https://github.com/hyperapp/hyperapp/issues/546
MDCTabBar automatically initiates its children. So initiating tabs will result in that error.
The fix is to just initiate MDCTabBar

using qtip in xpages

i'm trying to display qtip2 for certain xpage Components. To make it generic, i have created a custom control which has (fieldID & componentID as custom properties). i have a view which has all fieldID's and associated help text for each id ( which is unique)
My problem is that i'm unable to call a SSJS function from CSJS with input parameters. Please see my code below. if i hardcode fieldID (getFieldHelp('"+fieldID+"')) everything works fine but when i pass variable it will return null value. Any help will be greatly appreciated. thanks in advance.
script block
<xp:scriptBlock id="scriptBlock2"
value="var fieldID=#{compositeData.fieldID};var componentID=#{compositeData.componentID};">
</xp:scriptBlock>
on client load event
alert(componentID+"~~~~~~~~~~~"+fieldID)
var helpContent="#{javascript:getFieldHelp('"+fieldID+"')}"
alert(helpContent)
$(document).ready(function()
{
x$("#{id:link_Test}").qtip({
//x$(compid).qtip({
content: "helpContent",
style: 'qtip-tipsy qtip-shadow'
});
});
This will not work. If you want to send a ClientSide variable 'fieldID' to a SSJS (getFieldHelp) you have to use something like the ExecuteOnServer function from Jeremy Hodge. because you have to POST this variable to the Server.
But why dont you use:
var helpContent ="#{javascript:getFieldHelp(compositeData.fieldID)}"
assuming that getFieldHelp is a SSJS function and both code snippets are in the same component. =)
(maby you have to Change the # to $ to get the compositeData.)
update:
I did some testing on getting the compositeData.FieldID in an CSJS onClientLoad event.
What i came up with is this:
<xp:scriptBlock>
<xp:this.value><![CDATA[XSP.addOnLoad(function(){
alert("#{javascript:return compositeData.fieldId}");
});]]></xp:this.value>
</xp:scriptBlock>
I use the XSP.addOnLoad() to execute the CSJS (onClientLoad) and inside the xp:scriptBlock i can pass the compositeData to the client side.

Is there an example for putting the mediaroutebutton on the action bar?

I have it working with the following code on onPrepareMenuOptions but it doesn't work well.
MenuItem mediaRouteItem = menu.findItem(R.id.media_route_button);
mMediaRouteButton = (MediaRouteButton) mediaRouteItem.getActionView();
mMediaRouteButton.setRouteSelector(mMediaRouteSelector);
mDialogFactory = new SampleMediaRouteDialogFactory();
mMediaRouteButton.setDialogFactory(mDialogFactory);
I was hoping to compare it against some code that wasn't written by guessing what to do.
Thanks.
EDIT: I just converted my code to use what is suggested here https://stackoverflow.com/questions/17911796/displaying-the-mediaroutebutton-for-chromecast-in-the-action-bar and had the exact same issues. And if I leave the code with onCreateOptionsMenu then the button is always disabled.

jscrollpane colors

I'm trying to modify the scrollbar colors for jscrollpane.
This didn't work for me:
$('a.athlete_popup_content').click(function(){
$('#box_on_top').append($content); //.athlete class is within $content
$('.athlete').jScrollPane({autoReinitialise: true});
$('.jspVerticalBar').css('width', '10px');
$('.jspTrack').css('background','lightgrey');
$('.jspDrag').css('background','black');
$('.athlete').jScrollPane({autoReinitialise: true});
});
i tried placing athlete class both before and after... it doesn't do anything... also, the second time this runs, the scrollbar doesn't appear at all.
any help?
-=update=-
For the issue where it does not appear correctly the second time, I had to destroy the jsp on close and it started working.
var element = $('.athlete').jScrollPane();
var api = element.data('jsp');
api.destroy();
I was unable to get the colors to work.
I am including the .css initially, but want to change the colors on load. I wasn't able to figure out this issue so I just modified the .css
Thanks!
Your code es working perfectly, as you can see here. If you are calling jScrollPane() on a click event then the tags you are trying to reach (.jspVerticalBar, .jspTrack, .jspDrag) are created after css() calls, then you should use .on() to attach those calls to the event.

raphael text() not working in ie9

Why is the following example not working in ie9?
http://jsfiddle.net/dzyyd/2/
It spits out a console error:
"Unexpected call to method or property access."
I found it pretty quickly. You created the element, but did not put it anywhere. Once it is added to the document body, everything seems to be fine.
this._width=300;
this._height=300;
this._bgSvgContainer = document.createElement("div");
//NOTE: add the created div to the body of the document so that it is displayed
document.body.appendChild(this._bgSvgContainer);
var bgCanvas = Raphael(this._bgSvgContainer, this._width, this._height);
this._bgCanvas = bgCanvas;
var num = this._bgCanvas.text(this._width-10,this._height-10,"1");
It's really hard to tell with such a tiny code-fragment (doesn't run on any browser for me), but it's probably a scope issue this in IE during events is completely different to this using the W3C event model. See: quirksmode-Event order-Problems of the Microsoft model

Resources