Archives for categorie "Dojo"

Class URLLoader allow to load resources online and verify it state to take another actions.

An use example could be to check a server to show an alert when it was down:


Source codeClick with the right button to obtain source code.

ArrayCollection class wraps Array class and give it new functionalities but it blocks access to Array methods like push, pop and so on.

However, you can use ArrayCollection data source directly:

ArrayCollection.source=array;

Flex applications with file upload through HTTPS has a security violation problem accepted by Internet community and it has no easy solution.

Although there are workaround proposed by the flex community, it not ever work and finally it’s better to use Flex and HTML mixed solutions.

Then is interesting to use javascript libraries as Dojo and ExternalInterface class which Flex use to communicate with the browser.

Following there is a simple example:


Source codeClick with the right button to obtain source code.

Functionality doesn´t solve managing files because is a very common HTML implementation.

Example to convert Date to String and String to Date using Dojo 1.1.

String format must match with dojo ‘locale’. That can be achieve automatically or using dojo.locale=’es-es’.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>String to Date</title>
<script type="text/javascript"
    src="http://o.aolcdn.com/dojo/1.0.0/dojo/dojo.xd.js"
    djConfig="parseOnLoad: true, isDebug:true"></script>
    <script type="text/javascript">
        dojo.require("dojo.i18n");
        dojo.require("dojo.date.locale");
	dojo.require("dojo.parser");
        function init() {
            // Date to String
            var d1=new Date();
            var DtoS =    dojo.date.locale.format(d1, {
                            datePattern:"dd 'de' MMMM 'de' yyyy HH:mm:ss",
                            selector:"date",
                            locale:'es-es'});
            console.debug('Date to String: '+DtoS);
            dojo.byId('d1').innerHTML=DtoS;
            // String to Date
            var StoD =    dojo.date.locale.parse(DtoS,{
                            selector: 'date',
                            datePattern:"dd 'de' MMMM 'de' yyyy HH:mm:ss"
                        })
            console.debug('String to Date: '+StoD.toString());
            dojo.byId('d2').innerHTML=StoD.toString();
        }
        dojo.addOnLoad(init);
    </script>
</head>
    <body>
        <div>Date to String: </div>
        <div>String to Date: </div>
    </body>
</html> 

Parse a date like 06/26/2008 (with format MM/dd/yyyy) with locale=’es-es’ will produce an error.

Delete a FilteringTable row in Dojo 0.4.3.

// Delete table row (table 'valueField' must match with field name of 'id')
var table=dojo.widget.byId('tableID');
var data=table.store;
data.removeData(data.getData()[data.getIndexOf(idValue)]);
table.store.setData(data.getData())
Creative Commons License
This blog is under Creative Commons licence, unless indicated otherwise.
Special thanks to Mark James for the icon set used in this blog.