Using computed value from datasource value in design definition - xpages
I have a custom control with a computed title in Design Definition:
text="<%=this.titleBarText%>">
I want to pass a title, computed by javascript:
document1.isNewNote()?'New document':'Edit document'
When i try it, I have an error:
Error generating custom visualisation for this custom control. Markup validation failed. Ensure 'Design Definition' source is valid.
My custom control works fine in browser, but I can't edit it in WYSIWYG-editor.
How can I handle this error?
Design definition:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:panel style='background-color:rgb(255, 255, 255);border-bottom-color:rgb(221, 221, 221);border-bottom-left-radius:4px;border-bottom-right-radius:4px;border-bottom-style:solid;border-bottom-width:1px;border-image-outset:0px;border-image-repeat:stretch;border-image-slice:100%;border-image-source:none;border-image-width:1;border-left-color:rgb(221, 221, 221);border-left-style:solid;border-left-width:1px;border-right-color:rgb(221, 221, 221);border-right-style:solid;border-right-width:1px;border-top-color:rgb(221, 221, 221);border-top-left-radius:4px;border-top-right-radius:
4px;border-top-style:solid;border-top-width:1px;box-shadow:rgba(0, 0, 0, 0.05) 0px 1px 2px 0px;box-sizing:border-box;color:rgb(51, 51, 51);display:block;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif
;font-size:14px;height:96px;line-height:20px;margin-bottom:20px;text-size-adjust:100%;width:592px;-webkit-tap-highlight-color:rgba(0, 0, 0, 0);'>
<xp:panel style='background-color:rgb(245, 245, 245);background-image:linear-gradient(rgb(245, 245, 245) 0px, rgb(232, 232, 232) 100%);background-repeat-x:;background-repeat-y:;border-bottom-color:
rgb(221, 221, 221);border-bottom-style:solid;border-bottom-width:1px;border-left-color:rgb(221, 221, 221);border-right-color:rgb(221, 221, 221);border-top-color:rgb(221, 221, 221);border-top-left-radius:3px;border-top-right-radius:3px;box-sizing:border-box;color:rgb(51, 51, 51);display:block;filter:
none;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;font-size:14px;height:43px;line-height:20px;padding-bottom:10px;padding-left:15px;padding-right:15px;padding-top:10px;text-size-adjust:100%;width:590px;-webkit-tap-highlight-color:rgba(0, 0, 0, 0);'>
<xp:link escape="true" style='background-color:rgba(0, 0, 0, 0);box-sizing:border-box;color:rgb(51, 51, 51);cursor:auto;display:inline;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;font-size:16px;height:auto;line-height:22.8571px;margin-bottom:0px;margin-top:0px;text-decoration:none;text-size-adjust:100%;width:
auto;-webkit-tap-highlight-color:rgba(0, 0, 0, 0)'
text="<%=(this.titleBarText?this.titleBarText:'Computed')%>">
</xp:link>
</xp:panel>
<xp:panel style='box-sizing:border-box;color:rgb(51, 51, 51);display:block;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;font-size:14px;height:51px;line-height:20px;text-size-adjust:100%;width:590px;-webkit-tap-highlight-color:rgba(0, 0, 0, 0)'>
<xp:panel style='border-top-color:rgb(221, 221, 221);box-sizing:border-box;color:rgb(51, 51, 51);display:block;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;font-size:14px;height:30px;line-height:20px;padding-bottom:15px;padding-left:15px;padding-right:15px;padding-top:15px;text-size-adjust:100%;width:590px;-webkit-tap-highlight-color:rgba(0, 0, 0, 0)'>
<xp:callback facetName="panelBody" id="panelBody"></xp:callback>
</xp:panel>
<% if(this.footer!='false' ){ %>
<xp:panel style='background-color:rgb(245, 245, 245);border-bottom-left-radius:3px;border-bottom-right-radius:3px;border-top-color:rgb(221, 221, 221);border-top-style:solid;border-top-width:1px;box-sizing:border-box;color:rgb(51, 51, 51);display:block;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;font-size:14px;height:21px;line-height:20px;padding-left:15px;padding-right:15px;text-size-adjust:100%;width:590px;-webkit-tap-highlight-color:rgba(0, 0, 0, 0)'>
<xp:callback facetName="panelFooter" id="panelFooter"></xp:callback>
</xp:panel><% }%>
</xp:panel>
</xp:panel>
</xp:view>
document1.isNewNote() is a test to check if a document opened in browser or XPiNC is new. This is a test at runtime.
You are looking for presenting your custom control at design time in Designer. At this time there is no document you can show the status of.
It seems that the only way is to create new callback and compute the title inside the main xpage.
Add new Property Definition:
Add new callback and modify rendered property of a link:
<xp:callback facetName="customTitle" id="customTitle"
rendered="#{javascript:compositeData.custom_title}">
</xp:callback>
<xp:link escape="true" styleClass="panel-title"
text="#{javascript:compositeData.titleBarText}"
rendered="#{javascript:!compositeData.custom_title}">
<xp:this.attrs>
<xp:attr name="id">
<xp:this.value><![CDATA[#{javascript:compositeData.panel_id + "_title"}]]></xp:this.value>
</xp:attr>
</xp:this.attrs>
<xp:this.id><![CDATA[${javascript:compositeData.panel_id + "_title"}]]></xp:this.id>
</xp:link>
Change Design Definition:
That's all. Just insert cumputed link in the main XPage:
Related
PDF is cutting down from right when exporting using node js html-pdf
I am having a task in my project to convert a html file into pdf. It has been done successfully using html-pdf. But the problem is when I am running this in my localhost the pdf coming fine but if I am try this same at our development server then the pdf has been cutting down from right wise. My pdf generation script is var fs = require('fs'); var pdf = require('html-pdf'); var html = fs.readFileSync('ticket.html', 'utf8'); var options = { format: 'Letter' }; pdf.create(html, options).toFile('pdf/newpdftemplate.pdf', function(err, res) { if (err) return console.log(err); }); Please suggest if any settings I need to change or add any new script to do this. Also sharing the html script here <div class="pageContatiner noSelect ui-droppable slctCon" style="width: 6px; height: 500px;"><span class="bd1"></span><span class="bd2"></span><span class="bd3"></span><span class="bd4"></span><div class="ft-container"><div onmousedown="objSelection(this)" ontouchstart="objSelection(this)" id="pmObj-1" class="shape obj ft-widget" style="left: 330px; top: 118px; width: 100px; height: 100px; position: absolute;-webkit-transform:none;-moz-transform:none;-o-transform:none;transform:none;-ms-transform:none;"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" height="102" width="102"><rect class="svgObj" x="1" y="1" height="100" width="100" stroke="rgba(51,122,183,0.99)" stroke-width="1" fill="rgba(51,122,183,1)"></rect></svg></div><div class="ft-controls" style="top: 118.333px; left: 330px; width: 100px; height: 100px; transform: matrix(1, 0, 0, 1, 0, 0); transform-origin: 50% 50% 0px; visibility: hidden;"><div class="ft-rotator" style="transform: matrix(1, 0, 0, 1, 0, 0); transform-origin: 50% 50% 0px; top: -20px; left: 66px;"><i class="fa fa-undo" aria-hidden="true"></i></div><div class="ft-delete"><i class="fa fa-times" aria-hidden="true"></i></div><div class="ft-check"><i class="fa fa-check" aria-hidden="true"></i></div><div class="ft-scaler ft-scaler-top ft-scaler-left ft-scaler-tl"></div><div class="ft-scaler ft-scaler-top ft-scaler-right ft-scaler-tr"></div><div class="ft-scaler ft-scaler-bottom ft-scaler-right ft-scaler-br"></div><div class="ft-scaler ft-scaler-bottom ft-scaler-left ft-scaler-bl"></div><div class="ft-scaler ft-scaler-top ft-scaler-center ft-scaler-tc"></div><div class="ft-scaler ft-scaler-bottom ft-scaler-center ft-scaler-bc"></div><div class="ft-scaler ft-scaler-mid ft-scaler-left ft-scaler-ml"></div><div class="ft-scaler ft-scaler-mid ft-scaler-right ft-scaler-mr"></div><div class="ft-scaler ft-scaler-mid ft-scaler-center ft-scaler-mc"></div></div></div></div>
Fabric.js: Initial position object outside canvas no longer working
Recently I have started to use a newer version of Fabric.js (from 1.7.22 to 2.3.5). I had to make a few modifications to existing code that seem logical to me. However, I notice that you cannot initially place an object outside the canvas anymore, to reposition it later onto the canvas. Like in the code below. It won't show. My question is: has this changed for some reason, or is this an issue (bug)? And do I have other options than postpone adding the object to the canvas, or using the visible attribute? $( document ).ready(() => { const canvas = new fabric.Canvas('canvas'); var rect = new fabric.Rect({ left: 301, top: 10, originX: 'left', originY: 'top', width: 50, height: 50, fill: '#336699' }); canvas.add(rect); rect.set({"left": 10}); rect.set({"top": 10}); canvas.renderAll(); }); canvas { border: 1px solid tomato; } <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/2.3.5/fabric.min.js"></script> <canvas id="canvas" width="300" height="100"></canvas>
You need to use setCoords() after repositioning. $( document ).ready(() => { const canvas = new fabric.Canvas('canvas'); var rect = new fabric.Rect({ left: 301, top: 10, originX: 'left', originY: 'top', width: 50, height: 50, fill: '#336699' }); canvas.add(rect); rect.set({"left": 10}); rect.set({"top": 10}); rect.setCoords(); canvas.renderAll(); }); canvas { border: 1px solid tomato; } <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/2.3.5/fabric.min.js"></script> <canvas id="canvas" width="300" height="100"></canvas>
How to change dojodatetimetextbox icon in XPages
I tried to replace Dojo DateTimeBox icon with a new One. The CSS does not work. I use that CSS code But It does not work :( .dijitDateTextBox .dijitArrowButton .dijitArrowButtonInner { background-image: url('calendar_32x32.png') !important; } <xp:inputText id="eDate" value="#{document1.eDate}" dojoType="dijit/form/DateTextBox"> <xp:dateTimeHelper id="dateTimeHelper1"> </xp:dateTimeHelper> <xp:this.converter> <xp:convertDateTime type="date" dateStyle="short"> </xp:convertDateTime> </xp:this.converter> </xp:inputText>
If you set the background image on the dijitArrowButton class you might get a better result. Your CSS code would be: .dijitDateTextBox .dijitArrowButton .dijitArrowButtonInner { background-image: none !important; } .dijitDateTextBox .dijitArrowButton { background-image: url('calendar_32x32.png') !important; background-repeat: no-repeat; background-position: center; }
Xpages Bootstrap Modal - how to make it draggable
I am using bootstrapResponsiveConfiguration on Domino Server: 9.0.1 FP6 with Ext Lib version - ExtensionLibraryOpenNTF-901v00_17.20160428-0214 The dialog control (Modal in bootstrap) is not draggable. How to make dialog control draggable? <?xml version="1.0" encoding="UTF-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex"> <xe:applicationLayout id="applicationLayout1"> <xp:panel> <xp:button id="button1" styleClass="btn-primary" value="Show Dialog"> <i class="fa fa-user" /> <xp:eventHandler event="onclick" submit="false"> <xp:this.script><![CDATA[//getComponent("dialog1").show(); XSP.openDialog("#{id:dialog1}")]]></xp:this.script> </xp:eventHandler> </xp:button> <xe:dialog id="dialog1" title="Dialog Title"> <xe:this.onShow> <![CDATA[$(".xsp-responsive-modal").removeClass("xsp-responsive-modal").addClass("my-responsive-modal");]]> </xe:this.onShow> <xp:table> <xp:tr> <xp:td> <xp:label value="Label"></xp:label> </xp:td> <xp:td> <xp:inputText></xp:inputText> </xp:td> </xp:tr> </xp:table> <xe:dialogButtonBar> <xp:button value="Cancel"></xp:button> <xp:button value="Save" styleClass="btn-primary"></xp:button> </xe:dialogButtonBar> </xe:dialog> </xp:panel> <xp:this.facets> <xe:navigator id="navigator1" xp:key="LeftColumn"> <xe:this.treeNodes> <xe:basicLeafNode label="Link 1"></xe:basicLeafNode> <xe:basicLeafNode label="Link 2"></xe:basicLeafNode> </xe:this.treeNodes> </xe:navigator> </xp:this.facets> <xe:this.configuration> <xe:bootstrapResponsiveConfiguration productLogo="/car.png" placeBarName="New Application Name" placeBar="true" titleBar="false" invertedNavbar="true" collapseLeftColumn="true" collapseLeftMenuLabel="Menu Title" footer="false" legal="false"> <xe:this.bannerUtilityLinks> <xe:loginTreeNode styleClass="logout"></xe:loginTreeNode> <xe:basicLeafNode label="#{javascript:#UserName();}" styleClass="username"></xe:basicLeafNode> </xe:this.bannerUtilityLinks> <xe:this.placeBarActions> <xe:basicLeafNode label="Link 1"></xe:basicLeafNode> <xe:basicLeafNode label="Link 2"></xe:basicLeafNode> </xe:this.placeBarActions> </xe:bootstrapResponsiveConfiguration> </xe:this.configuration> </xe:applicationLayout> </xp:view> I have added the CSS inside the stylesheet, and included it in theme.: .my-responsive-modal { display: block; width: auto; left: 0; top: 0; z-index: 1050 !important; }
The .xsp-responsive-modal class in xsp-mixin.css is using !important on the left and top properties preventing the modal from being draggable. I worked around this by replacing the .xsp-responsive-modal class with my own class, .my-responsive-modal that does not use !important. To replace the class I use the onShow event of the dialog: <xe:this.onShow> <![CDATA[ x$("#{id:dialog1}").removeClass("xsp-responsive-modal").addClass("my-responsive-modal"); ]]> </xe:this.onShow> Here is the .my-responsive-modal class: .my-responsive-modal { /* copy of .xsp-responsive-modal with important removed from left and top to enable dragging in xe:dialog */ display: block; width: auto; left: 0; top: 0; z-index: 1050 !important; } Note: the x$() function is a handy utility from Mark Roden to escape ':' in ids so that they work with JQuery (https://openntf.org/XSnippets.nsf/snippet.xsp?id=x-jquery-selector-for-xpages)
Position fabric.js text by baseline
In native HTML5 canvas the text is positioned by the text baseline but in Fabric.js it seems to be by the bottom of the text. I want Fabric.js to position text by the baseline. Is it possible? See image This is the code used for the example. Fabric.js<br /> <canvas id="fabric" width="300" height="300" style="border:1px solid #d3d3d3;"></canvas> <script src="fabric.js"></script> <script> var canvas = new fabric.Canvas('fabric'); canvas.add(new fabric.Line([100, 100, 200, 100], { left: 10, top: 50, stroke: 'red' })); canvas.add(new fabric.Text('Hello World', { left: 10, top: 50, originY: 'bottom', useNative: true, fontSize: 50 })); </script> <br /> Native HTML5<br /> <canvas id="native" width="300" height="300" style="border:1px solid #d3d3d3;"></canvas> <script> var c = document.getElementById("native"); var ctx = c.getContext("2d"); ctx.font = "50px Times New Roman"; ctx.fillText("Hello World",10,50); ctx.moveTo(10,50); ctx.lineTo(100,50); ctx.strokeStyle = '#ff0000'; ctx.stroke(); </script>
Unfortunately, it doesn't look possible at the moment. The textBaseline attribute is set to 'alphabetic' and the only available vertical alignment options are 'top', 'center', & 'bottom' (which are relative to the bounding box fabric draws around the text). I've created an issue to request this feature. Hopefully, they add it!