This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Aug 1, 2011, 12:25 PM
33 Posts
topic has been resolvedResolved

Getting a colour picker to work in my XPage

  • Category: Dojo and Client Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 2
Hi all
 
I've been struggling to get a colour picker working in my XPage...   This is as far as I have got:
 
1. Successfully got the dojo colour picker working on my XPage
2. Able to write selected colour hex code to the screen via a javascript alert
 
The problem I have now is I cannot work out how to get this value into an XPages field.
 
Has anyone successfully implemented this?
 
Here is my code so far:
 

<?xml version="1.0" encoding="UTF-8"?>

<xp:view xmlns:xp="http://www.ibm.com/xsp/core" dojoParseOnLoad="true"

dojoTheme="true">

 

<head>

<style type="text/css">

body, html { font-family:helvetica,arial,sans-serif; font-size:90%; }

</style>

<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/dojo.xd.js"

djConfig="parseOnLoad: true"/>

<script type="text/javascript">

dojo.require("dojox.widget.ColorPicker");

dojo.addOnLoad(function() {

var c = new dojox.widget.ColorPicker({},

"picker1");

});

</script>

<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dijit/themes/claro/claro.css"

/>

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojox/widget/ColorPicker/ColorPicker.css"

/>

</head>

<body class=" claro ">

<div id="holder" dojoType="dojox.widget.ColorPicker"

value="#9ebf6c"

onChange="handler(arguments[0],'onchangeOne')"

/>

</body>

<xp:br/>

<p>Current value: <input readonly="true" id="onchangeOne" value="???" /></p>

Here is the value:&#160;&#160;&#160;&#160;

<xp:inputText id="a"></xp:inputText>

<script type="text/javascript">

var handler = function(val,id){

dojo.byId(id).value = val;

alert(val);

};

</script>

</xp:view>

    
Aug 1, 2011, 1:13 PM
272 Posts
Re: Getting a colour picker to work in my XPage
Hi Ian,
 
just embed your function in an output script block, then you can access the field with the '#{id:NAME_OF_FIELD}' syntax:
 
    <xp:scriptBlock id="scriptBlock1">
        <xp:this.value><![CDATA[
var handler = function(val,id){
dojo.byId('#{id:a}').value = val;
};]]></xp:this.value>
    </xp:scriptBlock>
 
 
Sven
 
Aug 1, 2011, 3:57 PM
33 Posts
Re: Getting a colour picker to work in my XPage
That worked a treat - thanks very much!
 
Much look into ScriptBlocks and what they do, exactly... 
 
Thanks again. 
 
 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal