BootstrapValidator dosen't work with xpages? - xpages

i'm a beginner in bootstrap,i was trying to build an Xpage with the BootstrapValidator to validate an inputText but it dosen't work,below the code source,can we help me to find a solution!
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xc="http://www.ibm.com/xsp/custom">
<xp:this.resources>
<xp:styleSheet href="/bootstrapValidator/css/bootstrap.css"></xp:styleSheet>
<xp:styleSheet href="/bootstrapValidator/css/bootstrapValidator.css"></xp:styleSheet>
<xp:script src="/JQueryXSnippet.js" clientSide="true"></xp:script>
<xp:script src="/bootstrapValidator/js/bootstrap.min.js" clientSide="true"> </xp:script>
<xp:script src="/bootstrapValidator/js/bootstrapValidator.js" clientSide="true"></xp:script>
</xp:this.resources>
<div class="col-md-5">
<xp:inputText id="username" title=" username"></xp:inputText>
</div>
<xp:scriptBlock id="scriptBlock1">
<xp:this.value><![CDATA[$(document).ready(
function() {
$("#{id:username}" ).bootstrapValidator({
message: 'This value is not valid',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
username: {
message: 'The username is not valid',
validators: {
notEmpty: {
message: 'The username is required and can\'t be empty'
},
stringLength: {
min: 6,
max: 30,
message: 'The username must be more than 6 and less than 30 characters long'
},
regexp: {
regexp: /^[a-zA-Z0-9_\.]+$/,
message: 'The username can only consist of alphabetical, number, dot and underscore'
}
}
} } });
]]></xp:this.value>
</xp:scriptBlock>
</xp:view>

Use the XPages compatible jQuery selector x$ instead of the native jQuery $ selector.
Also try using XSP.addOnLoad() instead of (document).ready().
Furthermore, your XPages xp:inputText field called "username" has an id in the browser called something like "view:_id1:_id2:_id8:username". So it's not called "username" as stated in your fields definition for bootstrapValidator. Therefore bootstrapValidator is unable to find the field. Try adding this to your scriptBlock instead of "username: {":
#{id:username}: {

Related

Adding Dropdowns in a vue.js router-link

I have created a vue.js router and inserting the links found in an array using the structure found hereafter. This displays the links horizontally. However, I would like to insert dropdowns, instead of simple links. Can this be done using this or similar structure somehow?
<nav style="text-align: right">
<router-link class="spacing" v-for="routes in links"
v-bind:key="routes.id"
:to="`${routes.page}`">{{routes.text}}</router-link>
</nav>
links: [
{
id: 0,
text: 'Buy',
page: '/Buy'
},
{
id: 1,
text: 'Sale',
page: '/Sale'
},
{
id: 2,
text: 'Transactions',
page: '/Transactions'
},
{
id: 3,
text: 'Help',
page: '/Help'
}
]
Yeah, there are a few ways you could do that, though you'll have to loop over something different than the <router-link>, since that component renders an <a> tag.
I would first adjust your HTML to allow for the drop-down interaction you want, whether it's hover- or click-based, then change your data structure and loop to support it.
I might do something like this:
<nav style="text-align: right">
<div
class="nav-item"
v-for="link in links" // Move loop to container of shown link and it's dropdown markup
>
<router-link
:key="link.id"
:to="`${link.page}`"
>
{{ link.text }}
</router-link>
<div class="nav-item-drawer">
<router-link
v-for="subLink in link.subLinks"
:key="subLink.id"
:to="`${subLink.page}`"
>
{{ subLink.text }}
</router-link>
</div>
</div>
</nav>
with the following data structure:
links: [
{
id: 0,
text: 'Buy',
page: '/Buy',
subLinks: [
{
id: 0,
text: 'Buy Sublink 1',
page: '/Buy-more'
},
{
id: 1,
text: 'Buy Sublink 2',
page: '/Buy-less'
},
]
},
{
id: 1,
text: 'Sale',
page: '/Sale'
},
//...
]

dojox.data is undefined while trying to create a dojo data grid

I'm using XPages and attempting to create a dojo enhanced data grid for the first time. I'm following examples I found online, but am getting the error: "dojox.data is undefined". I hardly found anything about this error, so apparently it must be something simple to everyone else. I'm a little lost here, can someone point me in the right direction to get this resolved?
My goal is to query data from an ERP System and then display it in the grid. However, I need to get it working with hard coded data first.
Here is my xpage source:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" dojoParseOnLoad="true"
dojoTheme="true">
<xp:this.resources>
<xp:dojoModule name="dojox.grid.EnhancedGrid"></xp:dojoModule>
<xp:dojoModule name="dojox.grid.enhanced.plugins.DnD"></xp:dojoModule>
<xp:dojoModule
name="dojox.grid.enhanced.plugins.NestedSorting">
</xp:dojoModule>
<xp:dojoModule
name="dojox.grid.enhanced.plugins.IndirectSelection">
</xp:dojoModule>
<xp:dojoModule name="dojox.grid.enhanced.plugins.Filter"></xp:dojoModule>
<xp:dojoModule name="dojox.data.ItemFileWriteStore"></xp:dojoModule>
<xp:styleSheet
href="/.ibmxspres/dojoroot/dijit/themes/dijit.css">
</xp:styleSheet>
<xp:styleSheet
href="/.ibmxspres/dojoroot/dojox/grid/resources/Grid.css">
</xp:styleSheet>
<xp:styleSheet
href="/.ibmxspres/dojoroot/dojox/grid/resources/tundraGrid.css">
</xp:styleSheet>
<xp:styleSheet
href="/.ibmxspres/dojoroot/dojox/grid/enhanced/esources/EnhancedGrid.css">
</xp:styleSheet>
<xp:styleSheet
href="/.ibmxspres/dojoroot/dojox/grid/enhanced/esources/tundraEnhancedGrid.css">
</xp:styleSheet>
</xp:this.resources>
<xp:br></xp:br>
<xp:div id="gridDiv"></xp:div>
<xp:eventHandler event="onClientLoad" submit="false">
<xp:this.script>
<xp:executeClientScript>
<xp:this.script><![CDATA[dojo.addOnLoad(function(){
//setup the grid layout, format = {'name': 'columntitle', 'field': 'fieldname'}
var layout = [{
defaultCell: {editable: false, type: dojox.grid.cells._Widget},
rows:[
{'field': "qtno", 'name': "Quote No.", 'width': '20px'},
{'field': "cusno", 'name': "Cust #", 'width': '20px'},
{'field': "cusnm", 'name': "Customer", 'width': '30px'},
{'field': "qtamt", 'name': "Quote Amt", 'width': '20px'},
]
}]
//setup data store
var data = {
identifier: 'id',
items: []
};
//setup data array of strings, format = {fieldname: "strvalue", fieldname: numvalue}
var data_list = [
{ qtno: "Q01234", cusno: "4419", cusnm: "ABC Corporation", qtamt: 29.91},
{ qtno: "Q42198", cusno: "3308", cusnm: "Acme Company", qtamt: 9.33},
{ qtno: "Q11095", cusno: "7041", cusnm: "XYZ Industries", qtamt: 19.34}
];
//default the rows
var rows = 100;
//populate the store with the data array of strings
for(var i=0, l=data_list.length; i<rows; i++){
data.items.push(dojo.mixin({ id: i+1 }, data_list[i%l]));
}
var store = new dojox.data.ItemFileWriteStore({data: data});
//define the grid
var grid = new dojox.grid.EnhancedGrid({
id: 'grid',
query: {},
store: store,
structure: layout,
rowSelector: '20px',
autoHeight: 25
}, '#{id:gridDiv}');
//create it
grid.startup();
})
]]></xp:this.script>
</xp:executeClientScript>
</xp:this.script></xp:eventHandler></xp:view>
and, here is the error:
TypeError: dojox.data is undefined
Stack trace:
view__id1__id3_clientSide_onClientLoad/<#http://domsvr3.mphassoc.com/dev/MiscDev.nsf/DataGrid.xsp:87:9
Use dojo.data as it’s no longer part of the experimental Dojo package dojox.
The dojox.data resource should have been dojo.data.

libxmljs: how to use xinclude?

I try to use libxmljs with nodejs.
In my sample I want to use the xi:include.
<ord:order xmlns:ord="http://example.org/ord"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://example.org/ord chapter04ord1.xsd"
xmlns:xi="http://www.w3.org/2001/XInclude">
<number>123ABBCC123</number>
<customer>
<name>Priscilla Walmsley</name>
<number>15466</number>
</customer>
<items>
<xi:include href="/Users/mar/ws_e/libxml/test/resources/chapter5prod.xml" />
</items>
</ord:order>
include File:
<ord:product xmlns:ord="http://example.org/ord"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://example.org/ord chapter04ord1.xsd">
<number>557</number>
<name>Short-Sleeved Linen Blouse</name>
<size system="US-DRESS">10</size>
<color value="blue"/>
</ord:product>
This is my code:
var xsdDoc = libxml.parseXml(schemaSource);
var xmlDocValid = libxml.parseXml(docSource);
var xmlDocInvalid = libxml.parseXml(xml_invalid);
xmlDocValid.validate(xsdDoc);
console.dir(xmlDocValid);
console.dir(xmlDocValid.validationErrors);
Then I get the error:
Document {
errors: [],
validationErrors:
[ { Error: Element '{http://www.w3.org/2001/XInclude}include': This element is not expected. Expected is ( product ).
So my question is how to use the x:include right at libxmljs?
Kind regards
Markus

Dojo grid display Error while using Row Select function with QueryreadStore

I have problem with dojo grid when i use gridx/modules/select/Row module, grid is not displayed. It gives Type Error: node is null.
My layout structure is here:
<script type="text/javascript">
var itemGridStore = new dojox.data.QueryReadStore({url:'invoiceConsignSearchStore'});
console.debug('store ::'+itemGridStore);
var layout=[
{id:"consId", field:"Consignment_Id", name:"Consignment Id", width:"23%"},
{id:"poDate", field:"Date", name:"Date", width:"30%"},
{id:"poNo", field:"PoSo_No", name:"Purchase Order No", width:"25%"},
{id:"refId", field:"Reference_Id", name:"Reference Id", width:"25%"},
{id:"customerName", field:"customerName", name:"Name/Company", width:"25%"},
{id:"location", field:"location", name:"Location", width:"25%"},
{id:"dealId", field:"Deal_Id", name:"Deal Id", width:"25%"}
];
var itemListgrid = new gridx.Grid({
cacheClass: gridx.core.model.cache.Async,
store: itemGridStore,
structure: layout,
modules: [
"gridx/modules/VirtualVScroller", "gridx/modules/SingleSort", "gridx/modules/CellWidget", "gridx/modules/Edit",
"gridx/modules/Filter", "gridx/modules/filter/FilterBar","gridx/modules/RowHeader","gridx/modules/select/Row", "gridx/modules/select/Cell"
],
vScrollerBuffSize: 30 ,
selectRowTriggerOnCell: true,
editLazySave: true
}, 'gridNode'); //Assume we have a node with id 'gridNode'
itemListgrid.startup();
itemListgrid.connect(itemListgrid,"onRowClick",function(evt){
var rowsSel=itemListgrid.select.row.getSelected();
console.debug('rowsSel ::'+rowsSel);
doImportSelectedItem(rowsSel);
});
</script>
<body class="tundra">
<!-- We'd like to show a grid here -->
<div align="center" id="gridNode"></div>
</body>
</html>
But without gridx/modules/select/Row this module it works fine. Can any one suggest the answer.
The select module requires Mark model extension, so your grid should look like:
var itemListgrid = new gridx.Grid({
cacheClass: gridx.core.model.cache.Async,
store: itemGridStore,
structure: layout,
modelExtensions: [
"gridx/core/model/extensions/Mark"
],
modules: [
"gridx/modules/VirtualVScroller",
"gridx/modules/SingleSort",
"gridx/modules/CellWidget",
"gridx/modules/Edit",
"gridx/modules/Filter",
"gridx/modules/filter/FilterBar",
"gridx/modules/RowHeader",
"gridx/modules/select/Row",
"gridx/modules/select/Cell"
],
vScrollerBuffSize: 30,
selectRowTriggerOnCell: true,
editLazySave: true
}, 'gridNode');
For modules compatibility take a look at this link: http://oria.github.io/gridx/moduleCompatibility.html

translation cannot work with symfony2.1

have a problem with translation is Symfony2.1
I tried almost all methods provided in the symfony_book but, only the translation from english to frensh that works, the reverse doesn't work
here is my routing.yml
_acceuil:
pattern: /{_locale}/acceuil/
defaults: { _controller: gestionConferenceApplicationBundle:acceuil:acceuil, _locale: en }
requirements:
_locale: en|fr|de
is my layout page I have thoses to links that allaw to switch between langage:
<a style="padding-top: -10px;" href="{{ path('_acceuil', {'_locale': 'fr' }) }}" >FRANCAIS</a>
<a style="padding-top: -10px;" href="{{ path('_acceuil', {'_locale': 'en' }) }}" >ANGLAIS</a>
and this line for test
{{ 'welcome in my site'|trans }}
and here is my messages.fr.xlf
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="1">
<source>welcome in my site</source>
<target>bienvenue dans mon site</target>
</trans-unit>
</body>
</file>
</xliff>
and here is my messages.en.xlf
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="fr" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="1">
<source>bienvenue dans mon site</source>
<target>welcome in my site</target>
</trans-unit>
</body>
</file>
</xliff>
and here is the part wwe are interested in my config.yml :
framework:
#esi: ~
translator: { fallback: en }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: "%kernel.debug%"
form: true
csrf_protection: true
validation: { enable_annotations: true }
templating: { engines: ['twig'] } #assets_version: SomeVersionScheme
default_locale: en
trust_proxy_headers: false # Whether or not the Request object should trust proxy headers (X_FORWARDED_FOR/HTTP_CLIENT_IP)
session: ~
and when I run I have always :
bienvenue dans mon site
how can I achieve that
thank you in advance
I know why your translations don't work.
Because the translation source is still this same. It's string from your template.
So ex:
{{'My Trans'|trans()}}
messages catalogues shoudl look like this fr:
'My Trans': 'My trans FR'
and the en trans:
'My Trans': 'My trans EN'
I hope this example will help you.

Resources