xpage with fullcalendar 2.2.5 - fullcalendar

I'd like to use fullCalendar in my xpage. It works with fullCalendar 1.6.7, not with 2.2.5 (nothing is displayed).
The sources are copied in package Explorer. This code works with the 1.6.7 sources:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.resources>
<xp:styleSheet href="fullcalendar/fullcalendar.css"></xp:styleSheet>
<xp:script src="js/jquery.min.js" clientSide="true"
type="text/javascript"></xp:script>
<xp:script src="fullcalendar/fullcalendar.min.js"
clientSide="true" type="text/javascript"></xp:script>
</xp:this.resources>
<xp:panel id="CalendarContainer"></xp:panel>
<xp:scriptBlock id="scriptBlock1">
<xp:this.value><![CDATA[var calCon = $("[id$=CalendarContainer]");
calCon.fullCalendar({});]]></xp:this.value>
</xp:scriptBlock>
The following code doesn't work with the 2.2.5 sources:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.resources>
<xp:styleSheet href="fullcalendar/fullcalendar.min.css"></xp:styleSheet>
<xp:script src="js/moment.min.js" clientSide="true"
type="text/javascript"></xp:script>
<xp:script src="js/jquery.min.js" clientSide="true"
type="text/javascript"></xp:script>
<xp:script src="fullcalendar/fullcalendar.min.js"
clientSide="true" type="text/javascript"></xp:script>
</xp:this.resources>
<xp:panel id="CalendarContainer"></xp:panel>
<xp:scriptBlock id="scriptBlock1">
<xp:this.value><![CDATA[var calCon = $("[id$=CalendarContainer]");
calCon.fullCalendar({});]]></xp:this.value>
</xp:scriptBlock>
</xp:view>
Any ideas?

Mark is right, You need to load the libraries before dojo
Here is the working code
<div class="cal"></div>
<xp:this.resources>
<xp:headTag tagName="script">
<xp:this.attributes>
<xp:parameter name="type" value="text/javascript" />
<xp:parameter name="src" value="jquery-2.1.3.min.js" />
</xp:this.attributes>
</xp:headTag>
<xp:headTag tagName="script">
<xp:this.attributes>
<xp:parameter name="type" value="text/javascript" />
<xp:parameter name="src" value="moment.min.js" />
</xp:this.attributes>
</xp:headTag>
<xp:headTag tagName="script">
<xp:this.attributes>
<xp:parameter name="type" value="text/javascript" />
<xp:parameter name="src" value="fullcalendar.min.js" />
</xp:this.attributes>
</xp:headTag>
<xp:styleSheet href="fullcalendar.min.css"></xp:styleSheet>
</xp:this.resources>
<xp:panel id="CalendarContainer"></xp:panel>
<xp:scriptBlock id="scriptBlock1">
<xp:this.value><![CDATA[var calCon = $(".cal");
calCon.fullCalendar({});]]></xp:this.value>
</xp:scriptBlock>
</xp:view>

I think that FullCalender started using an AMD loader for their JavaScript in v2. That doesn't play well with Dojo in XPages. See my answer here for more details and a possible solution.

The problem is - like Mark mentioned - that the current version uses AMD to load another library called "moment". This can be examined in the uncrompressed version of the fullcalendar.js file at the beginning. I made it working like this:
Create a theme and load all the resources there like
<theme
extends="yeti"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="platform:/plugin/com.ibm.designer.domino.stylekits/schema/stylekit.xsd">
<resource>
<content-type>application/x-javascript</content-type>
<href>bower_components/moment/moment.js</href>
</resource>
<resource>
<content-type>application/x-javascript</content-type>
<href>bower_components/fullcalendar/dist/fullcalendar.js</href>
</resource>
<resource>
<content-type>text/css</content-type>
<href>bower_components/fullcalendar/dist/fullcalendar.min.css</href>
</resource>
OR
load the moment.js also in your page resources separately.
Then open the fullcalendar.js file and edit the top of the code as follows (check the comments I made):
/*!
* FullCalendar v2.2.5
* Docs & License: http://arshaw.com/fullcalendar/
* (c) 2013 Adam Shaw
*/
(function(factory) {
/*
if (typeof define === 'function' && define.amd) {
define([ 'jquery', 'moment' ], factory);
}
else {
*/
factory(jQuery, moment);
//}
})(function($, moment) {
;;
I used the uncompressed version here to find the code but the compressed one is not such as obfuscated, so you should be able to add those comments there, too.
EDIT
I just saw Thomas' answer - that's the most elegant way to do it :-)

Related

After added new custom column in magento 2 filter not working for date sorting

I have added new column in sales order for coupon code. after added this column sorting working fine but when i am filtering for last day order it is showing something went wrong.
the ajax issue is in 'mui/index/render'
app\code\Vicomage\CustomCoupon\etc\di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="sales_order_grid_data_source" xsi:type="string">Vicomage\CustomCoupon\Model\ResourceModel\Order\Grid\Collection</item>
</argument>
</arguments>
</type>
</config>
app\code\Vicomage\CustomCoupon\etc\module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vicomage_CustomCoupon" setup_version="2.0.0">
</module>
</config>
app\code\Vicomage\CustomCoupon\Model\ResourceModel\Order\Grid\Collection.php
<?php
namespace Vicomage\CustomCoupon\Model\ResourceModel\Order\Grid;
use Magento\Sales\Model\ResourceModel\Order\Grid\Collection as OriginalCollection;
class Collection extends OriginalCollection{
protected function _renderFiltersBefore()
{
$joinTable = $this->getTable('sales_order');
$this->getSelect()->joinLeft($joinTable, 'main_table.entity_id = sales_order.entity_id', ['coupon_code']);
parent::_renderFiltersBefore();
}
}
app\code\Vicomage\CustomCoupon\view\adminhtml\ui_component\sales_order_grid.xml
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<column name="coupon_code">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Coupon Code</item>
</item>
</argument>
</column>
</columns>
</listing>
add below lines of code before parent::_renderFiltersBefore() in your file app\code\Vicomage\CustomCoupon\Model\ResourceModel\Order\Grid\Collection.php
$this->getSelect()->group('main_table.entity_id');
$this->getSelect()->group('main_table.store_id');
let me know if you still facing same issue.

Xpages: Getting FullCalendar to work with a bootstrap theme

Per's answer was a big part of the solution. For completeness here is what I ended up having to do.
First, I had to fix the AMD problem that Per mentioned.
Then I had to modify my Xpage to make sure that the proper libraries were loaded in the proper order. Some of this was done with trial and error.
I had to set the resource aggregation setting to true, but only for this design element. I do not understand why.
Then I needed to add 2 js libraries and one css library. The moment library had to be loaded first and by using a the head tag. Next I had to load the fullcalendar.min.js file but NOT using the headTag but a simple script, and then the css for fullcalendar using the style tag.
Doing this everything worked. Below is the code, and below that is my theme.....
Design code:
<xp:this.properties>
<xp:parameter name="xsp.resources.aggregate" value="true" />
</xp:this.properties>
<div class="cal"></div>
<xp:this.resources>
<xp:headTag tagName="script">
<xp:this.attributes>
<xp:parameter name="type" value="text/javascript" />
<xp:parameter name="src" value="FullCalendar/moment.min.js" />
</xp:this.attributes>
</xp:headTag>
<xp:script src="FullCalendar/fullcalendar.min.js"
clientSide="true">
</xp:script>
<xp:styleSheet href="FullCalendar/fullcalendar.min.css"></xp:styleSheet>
</xp:this.resources>
<xp:panel id="CalendarContainer"></xp:panel>
<xp:scriptBlock id="scriptBlock1">
<xp:this.value><![CDATA[$(document).ready(function() {
var calCon = $(".cal");
calCon.fullCalendar({});
})]]></xp:this.value>
</xp:scriptBlock>
</xp:view>
Theme code:
<!--
Use this pattern to include resources (such as style sheets
and JavaScript files that are used by this theme.
-->
<theme
extends="Bootstrap3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="platform:/plugin/com.ibm.designer.domino.stylekits/schema/stylekit.xsd">
<resource>
<content-type>application/x-javascript</content-type>
<href>/.ibmxspres/domino/KendoUI/js/jquery.min.js</href>
</resource>
--><resource>
<content-type>text/css</content-type>
<href>/.ibmxspres/domino/KendoUI/styles/kendo.common.min.css</href>
</resource>
<resource>
<content-type>text/css</content-type>
<href>/.ibmxspres/domino/KendoUI/styles/kendo.blueopal.min.css</href>
</resource>
<resource>
<content-type>application/x-javascript</content-type>
<href>/.ibmxspres/domino/KendoUI/js/kendo.all.min.js</href>
</resource>
</theme>
==================================================================
I want to use FullCalendar in my Xpages applications.
This code will work, as long as I don't use my standard theme. So "webstandard" and "platform default" are no problem, but Bootstrap doesn't work, nor my theme which extends bootstrap (see below)
<theme
extends="Bootstrap3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="platform:/plugin/com.ibm.designer.domino.stylekits/schema/stylekit.xsd">
<resource>
<content-type>application/x-javascript</content-type>
<href>/.ibmxspres/domino/KendoUI/js/jquery.min.js</href>
</resource>
--><resource>
<content-type>text/css</content-type>
<href>/.ibmxspres/domino/KendoUI/styles/kendo.common.min.css</href>
</resource>
<resource>
<content-type>text/css</content-type>
<href>/.ibmxspres/domino/KendoUI/styles/kendo.blueopal.min.css</href>
</resource>
<resource>
<content-type>application/x-javascript</content-type>
<href>/.ibmxspres/domino/KendoUI/js/kendo.all.min.js</href>
</resource>
</theme>
When I try to use my theme I get this error:
Uncaught TypeError: calCon.fullCalendar is not a function
I tried putting the js/css that I need to use in my theme, in the order that they need to be used, but this didn't work either.
I use the scoBootstrap throughout many applications, and don't want to not use it in applications that need a calendar. There must be some way for my javascript to live together...
Here is the code for the Xpage:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.properties>
<xp:parameter name="xsp.resources.aggregate" value="true" />
</xp:this.properties>
<div class="cal"></div>
<xp:this.resources>
<xp:headTag tagName="script">
<xp:this.attributes>
<xp:parameter name="type" value="text/javascript" />
<xp:parameter name="src" value="KendoUI/js/jquery.min.js" />
</xp:this.attributes>
</xp:headTag>
<xp:headTag tagName="script">
<xp:this.attributes>
<xp:parameter name="type" value="text/javascript" />
<xp:parameter name="src" value="FullCalendar/moment.min.js" />
</xp:this.attributes>
</xp:headTag>
<xp:headTag tagName="script">
<xp:this.attributes>
<xp:parameter name="type" value="text/javascript" />
<xp:parameter name="src" value="FullCalendar/fullcalendar.min.js" />
</xp:this.attributes>
</xp:headTag>
<xp:headTag tagName="script">
<xp:this.attributes>
<xp:parameter name="type" value="text/javascript" />
<xp:parameter name="src" value="FullCalendar/fullcalendar.min.js" />
</xp:this.attributes>
</xp:headTag>
<xp:styleSheet href="FullCalendar/fullcalendar.min.css"></xp:styleSheet>
</xp:this.resources>
<xp:panel id="CalendarContainer"></xp:panel>
<xp:scriptBlock id="scriptBlock1">
<xp:this.value><![CDATA[$(document).ready(function() {
var calCon = $(".cal");
calCon.fullCalendar({});
})]]></xp:this.value>
</xp:scriptBlock>
</xp:view>
FullCalendar uses AMD loading. Dojo and AMD loading conflicts so remove the AMD part from fullcalendar.min.js.
Change the first part of the source from this:
!function(t){"function"==typeof define&&define.amd?define
to this:
!function(t){"function"==typeof define&&false?define

Add border to button image for android

<Button
android:id="#+id/button_send"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:background="#drawable/buttons"
android:drawablePadding="10dp"
android:gravity="left"
android:padding="15dp"
android:text="Button"
android:textColor="#fff"
android:textSize="15sp" />
Above is my code for Button in My xml file.
My button.xml code is
<item android:drawable="#drawable/btn_bg_hover"
android:state_pressed="true" />
<item android:drawable="#drawable/btn_bg_default"
android:state_focused="true" />
<item android:drawable="#drawable/btn_bg_default"/>
kindly help me how to add border to that button.
Note: #drawable/btn_bg_hover is image
User stroke tag Android - border for button
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient android:startColor="#FFFFFF" android:endColor="#00FF00" android:angle="270" />
<corners android:radius="3dp" />
<stroke android:width="5px" android:color="#000000" />
You have to make your custom background drawable file and use it, the stroke property is the one you have to use for making border.
Steps :
Go to res -> drawable -> by right click -> new -> android drawable resource
copy paste this code
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#FFFFFF"
android:endColor="#00FF00"
android:angle="270" />
<stroke android:width="5px" android:color="#000000" />
</shape>
Here you see the stroke you can change values to make it in your way.
and use it as any components background by
<android:Background ="#drawable/yourCustomBorder.xml"> for example.

loading jars during splash screen

I have a main application which is referencing to 4-5 external jar files. So while compiling the project netbeans ide(javafx application) takes long time. Therefore I want to design a splash screen and which will be displayed till all jars gets loaded.
My JNLP file is
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0" xmlns:jfx="http://javafx.com" href="Black.jnlp">
<information>
<title>Black</title>
<vendor>RATTAN</vendor>
<description>Sample JavaFX 2.0 application.</description>
<offline-allowed/>
</information>
<resources>
<jfx:javafx-runtime version="2.2+" href="http://javadl.sun.com/webapps/download/GetFile/javafx-latest/windows-i586/javafx2.jnlp"/>
</resources>
<resources>
<j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
<jar href="Black.jar" size="3393158" download="eager" />
<jar href="lib/commons-io-1.3.2.jar" size="95655" download="eager" />
<jar href="lib/commons-lang-2.0.jar" size="179420" download="eager" />
<jar href="lib/newlink.jar" size="6160" download="eager" />
<jar href="lib/scribe-1.3.0.jar" size="74543" download="eager" />
</resources>
<security>
<all-permissions/>
</security>
<applet-desc width="800" height="600" main-class="com.javafx.main.NoJavaFXFallback" name="Black" >
<param name="requiredFXVersion" value="2.2+"/>
</applet-desc>
<jfx:javafx-desc width="800" height="600" main-class="test.Test" name="Black" />
<update check="always"/>
</jnlp>
Use preloaders module from JavaFx
here is complete tutorial:
http://docs.oracle.com/javafx/2/deployment/preloaders.htm
Good luck,'.

When using blazeDS's proxy-config throw faultDetail="Connection refused: connect"

I have created a XML file directly under the webroot, named index.jsp, the contents are as follow:
<%# page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<?xml version="1.0" encoding="utf-8"?>
<catalog>
<product>
<name>Product 1</name>
<description>Product 1 is good</description>
<price>5</price>
</product>
<product>
<name>Product 2</name>
<description>Product 2 is good</description>
<price>15</price>
</product>
<product>
<name>Product 2</name>
<description>Product 2 is good</description>
<price>25</price>
</product>
</catalog>
And in proxy-config.xml under the WEB-INF/flex:
<destination id="getXML">
<properties>
<url>http://localhost:8080/FlexTest/index.jsp</url>
</properties>
</destination>
In the main.mxml, the httpservice as follow:
<mx:HTTPService id="httpService" destination="getXML" useProxy="true" />
Corresponding DataGrid:
<mx:DataGrid dataProvider="{httpService.lastResult.catalog.product}" x="405" y="130" width="329" height="166"/>
But when I click the button to execute httpService.send(), some errors has been thrown up as follow:
[RPC Fault faultString="Error sending request" faultCode="Server.Proxy.Request.Failed" faultDetail="Connection refused: connect"]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[C:\autobuild\3.5.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:290]
at mx.rpc::Responder/fault()[C:\autobuild\3.5.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:58]
at mx.rpc::AsyncRequest/fault()[C:\autobuild\3.5.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:103]
at NetConnectionMessageResponder/statusHandler()[C:\autobuild\3.5.0\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:581]
at mx.messaging::MessageResponder/status()[C:\autobuild\3.5.0\frameworks\projects\rpc\src\mx\messaging\MessageResponder.as:222]
I hope someone could help me solve it out, thanks a lot.
Maybe you have to give to your HTTPService an url, like
<mx:HTTPService id="httpService" url="http://localhost:8080/FlexTest/index.jsp" destination="getXML" useProxy="true"/>

Resources