Steps to integrating Dojo with Zend Framework?

View: New views
8 Messages — Rating Filter:   Alert me  

Steps to integrating Dojo with Zend Framework?

by duyhung :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am having problems in setting up dojo in ZF. Here are my steps:
1. Download Dojo on Zend Framework standard incubator and place it in my Zend lib.
2. Add Dojo view helper in Bootstrap.php:
Code:
$view->addHelperPath(
        self::$root . '/library/Zend/Dojo/View/Helper',
        'Zend_Dojo_View_Helper_'
)
;
3. Tell dojo to use local path or CDN version in Bootstrap.php:
Having <?php echo $this->dojo() ?> in my layout script.
In case i want to use my local path, I was getting a "dojo is undefined" error showing up in firebug. So i think my path was setting up wrong. I placed the dojo lib inside js folder of the root:
Code:
$view->dojo()->setLocalPath('/js/dojo/dojo.js')
         ->addStyleSheetModule('dijit.themes.tundra');

I couldn't figure that out so i changed to use CDN version:
Code:
$view->dojo()->setCdnVersion('1.1.1');

The page started loading dojo but having an error showing in firebug:
Code:
Permission denied to get property XULElement.accessKey
XPCSafeJSObjectWrapper.cpp
Line 445

And also when I viewed source, the import CSS tundra was placed in a comment tag:
Code:
<style type="text/css">
<!--
    @import "http://o.aolcdn.com/dojo/1.1.1/dijit/themes/tundra/tundra.css";
-->
</style>


Googling a while but not many topics on Dojo - ZF integration, and I'm a newbie so I post it here.
All help is much appreciated,
Hung Nguyen

Re: Steps to integrating Dojo with Zend Framework?

by duyhung :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi again,

I've setup everything again and it didn't come up the error:
Permission denied to get property XULElement.accessKey
XPCSafeJSObjectWrapper.cpp
Line 445
anymore. So i think i installed incorrect version before. But still, the CSS theme's still in comment so no css loading. I had a look at Dojo/Container.php on line 897, I changed it so it wouldn't put the @import thingy in comment, but still no luck, no css loading.
I did addPrefixPath('Zend_Dojo_Form', 'Zend/Dojo/Form/') and created an username validation text box for my form:
Code:
        $username = $this->addElement('validationTextBox', 'name', array(
            'label' => 'Username:',
        'lowercase' => 'true',
        'maxlength' => 20,
        'regExp'    => '\w{3,}',
        'required' => true,
        'invalidMessage' => 'Username is not valid.',
    'filters'   => array(
        'StringTrim',
        'StringToLower',
    ),
    'validators' => array(
        'NotEmpty',
                        array('StringLength', true, array(3, 20)),
                        array('Regex', true, array('/\w+/i')),
    ),
        ));


and it turned out the following error:
Fatal error: Call to undefined method Zend_Dojo_Form_Element_ValidationTextBox::getFullyQualifiedName() in C:\Program Files\EasyPHP 2.0b1\www\Helpdesk\library\Zend\Dojo\Form\Decorator\DijitElement.php on line 181

I am totally lost now. Any ideas?

Re: Steps to integrating Dojo with Zend Framework?

by Matthew Weier O'Phinney-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-- duyhung <duyhung852002@...> wrote
(on Monday, 21 July 2008, 12:49 AM -0700):

> I've setup everything again and it didn't come up the error:
> Permission denied to get property XULElement.accessKey
> XPCSafeJSObjectWrapper.cpp
> Line 445
> anymore. So i think i installed incorrect version before. But still, the CSS
> theme's still in comment so no css loading. I had a look at
> Dojo/Container.php on line 897, I changed it so it wouldn't put the @import
> thingy in comment, but still no luck, no css loading.
> I did addPrefixPath('Zend_Dojo_Form', 'Zend/Dojo/Form/') and created an
> username validation text box for my form:
> Code:
>         $username = $this->addElement('validationTextBox', 'name', array(
>             'label' => 'Username:',
>         'lowercase' => 'true',
>         'maxlength' => 20,
>         'regExp'    => '\w{3,}',
>         'required' => true,
>         'invalidMessage' => 'Username is not valid.',
>     'filters'   => array(
>         'StringTrim',
>         'StringToLower',
>     ),
>     'validators' => array(
>         'NotEmpty',
>        array('StringLength', true, array(3, 20)),
>        array('Regex', true, array('/\w+/i')),
>     ),
>         ));
>
> and it turned out the following error:
> Fatal error: Call to undefined method
> Zend_Dojo_Form_Element_ValidationTextBox::getFullyQualifiedName() in
> C:\Program Files\EasyPHP
> 2.0b1\www\Helpdesk\library\Zend\Dojo\Form\Decorator\DijitElement.php on line
> 181
>
> I am totally lost now. Any ideas?

Yes; you're using old code.

Please update from current svn and use Zend_Dojo from
standard/trunk/library. It's clear from the above that you were using an
old incubator version that was not linked against the Zend_Form changes
made in trunk (which included the getFullyQualifiedName() method in the
base Zend_Form_Element class).

--
Matthew Weier O'Phinney
Software Architect       | matthew@...
Zend Framework           | http://framework.zend.com/

Re: Steps to integrating Dojo with Zend Framework?

by duyhung :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, I was using the old incubator version. Thanks Matthew, you saved my day. Btw, I'm wondering how can you set the password field (validationtextbox in my case) to be asterisk input as I haven't seen anyway to do that? I did read the ZF doc though.

Cheers, mate
Hung Nguyen

Matthew Weier O'Phinney-3 wrote:
Yes; you're using old code.

Please update from current svn and use Zend_Dojo from
standard/trunk/library. It's clear from the above that you were using an
old incubator version that was not linked against the Zend_Form changes
made in trunk (which included the getFullyQualifiedName() method in the
base Zend_Form_Element class).

--
Matthew Weier O'Phinney
Software Architect       | matthew@zend.com
Zend Framework           | http://framework.zend.com/

Re: Steps to integrating Dojo with Zend Framework?

by Matthew Weier O'Phinney-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-- duyhung <duyhung852002@...> wrote
(on Monday, 21 July 2008, 05:10 AM -0700):
> Yes, I was using the old incubator version. Thanks Matthew, you saved my day.

Glad I could help!

> Btw, I'm wondering how can you set the password field
> (validationtextbox in my case) to be asterisk input as I haven't seen
> anyway to do that? I did read the ZF doc though.

You know, really not sure. There isn't a dijit for password fields to my
knowledge. I'll ask on the #dojo IRC channel -- you might want to do the
same.

> Matthew Weier O'Phinney-3 wrote:
> >
> >
> > Yes; you're using old code.
> >
> > Please update from current svn and use Zend_Dojo from
> > standard/trunk/library. It's clear from the above that you were using an
> > old incubator version that was not linked against the Zend_Form changes
> > made in trunk (which included the getFullyQualifiedName() method in the
> > base Zend_Form_Element class).

--
Matthew Weier O'Phinney
Software Architect       | matthew@...
Zend Framework           | http://framework.zend.com/

Re: Steps to integrating Dojo with Zend Framework?

by Matthew Weier O'Phinney-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-- Matthew Weier O'Phinney <matthew@...> wrote
(on Monday, 21 July 2008, 12:37 PM -0400):

> -- duyhung <duyhung852002@...> wrote
> (on Monday, 21 July 2008, 05:10 AM -0700):
> > Yes, I was using the old incubator version. Thanks Matthew, you saved my day.
>
> Glad I could help!
>
> > Btw, I'm wondering how can you set the password field
> > (validationtextbox in my case) to be asterisk input as I haven't seen
> > anyway to do that? I did read the ZF doc though.
>
> You know, really not sure. There isn't a dijit for password fields to my
> knowledge. I'll ask on the #dojo IRC channel -- you might want to do the
> same.

It appears that you have two possibilities:

  * Create an element that extends ValidationTextBox or TextBox and
    which sets the 'type' dijit param to 'password'. (This will be the
    route I will officially take)
  * Alternately, pass the 'type' dijit parameter with the value
    'password' to either a TextBox or ValidationTextBox element. (You
    can do this _now_.)


> > Matthew Weier O'Phinney-3 wrote:
> > >
> > >
> > > Yes; you're using old code.
> > >
> > > Please update from current svn and use Zend_Dojo from
> > > standard/trunk/library. It's clear from the above that you were using an
> > > old incubator version that was not linked against the Zend_Form changes
> > > made in trunk (which included the getFullyQualifiedName() method in the
> > > base Zend_Form_Element class).

--
Matthew Weier O'Phinney
Software Architect       | matthew@...
Zend Framework           | http://framework.zend.com/

Re: Steps to integrating Dojo with Zend Framework?

by duyhung :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Matthew,

Do you mean I can use the getDijitParam('type') and setDijitParam('type','password')? I was playing with that a while but then when I looked into the Zend code, I think 'type' is not a dijit param. Correct me if I am wrong, mate. I found out that it's actually the HTML element type I need to change from 'text' to 'password' type. So I created an element PwdValidationTextBox extends the ValidationTextBox class:
Code:
<?php

require_once 'Zend/Dojo/Form/Element/ValidationTextBox.php';

class Helpdesk_Form_Element_PwdValidationTextBox extends Zend_Dojo_Form_Element_ValidationTextBox
{

    public $helper = 'PwdValidationTextBox';

}


And a view helper which is just almost identical to ValidationTextBox view helper but with a minor modification:
protected $_elementType = 'password';

I'm not sure it's a good way to implement it or not, but it's working now.

I'm really appreciated all your help,
Hung Nguyen

Matthew Weier O'Phinney-3 wrote:
-- Matthew Weier O'Phinney <matthew@zend.com> wrote
(on Monday, 21 July 2008, 12:37 PM -0400):
> -- duyhung <duyhung852002@yahoo.com> wrote
> (on Monday, 21 July 2008, 05:10 AM -0700):
> > Yes, I was using the old incubator version. Thanks Matthew, you saved my day.
>
> Glad I could help!
>
> > Btw, I'm wondering how can you set the password field
> > (validationtextbox in my case) to be asterisk input as I haven't seen
> > anyway to do that? I did read the ZF doc though.
>
> You know, really not sure. There isn't a dijit for password fields to my
> knowledge. I'll ask on the #dojo IRC channel -- you might want to do the
> same.

It appears that you have two possibilities:

  * Create an element that extends ValidationTextBox or TextBox and
    which sets the 'type' dijit param to 'password'. (This will be the
    route I will officially take)
  * Alternately, pass the 'type' dijit parameter with the value
    'password' to either a TextBox or ValidationTextBox element. (You
    can do this _now_.)

--
Matthew Weier O'Phinney
Software Architect       | matthew@zend.com
Zend Framework           | http://framework.zend.com/

Re: Steps to integrating Dojo with Zend Framework?

by Matthew Weier O'Phinney-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-- duyhung <duyhung852002@...> wrote
(on Tuesday, 22 July 2008, 05:59 AM -0700):
> Do you mean I can use the getDijitParam('type') and
> setDijitParam('type','password')? I was playing with that a while but then
> when I looked into the Zend code, I think 'type' is not a dijit param.
> Correct me if I am wrong, mate. I found out that it's actually the HTML
> element type I need to change from 'text' to 'password' type.

It is, but the functionality in the abstract Dijit helper will do one of
the following

 * If using declarative dojo, it will add the type HTML attribute.
   Whatever type attribute is defined last wins in HTML.

 * If using programmatic dojo, it will mixin the type HTML attribute,
   with the same result as above.

> So I created an element PwdValidationTextBox extends the
> ValidationTextBox class:
> Code:
> <?php
>
> require_once 'Zend/Dojo/Form/Element/ValidationTextBox.php';
>
> class Helpdesk_Form_Element_PwdValidationTextBox extends
> Zend_Dojo_Form_Element_ValidationTextBox
> {
>
>     public $helper = 'PwdValidationTextBox';
>
> }
>
> And a view helper which is just almost identical to ValidationTextBox view
> helper but with a minor modification:
> protected $_elementType = 'password';
>
> I'm not sure it's a good way to implement it or not, but it's working now.

It's actually how I plan to do this for RC2 (albeit with a different
helper name). :)


> Matthew Weier O'Phinney-3 wrote:
> >
> > -- Matthew Weier O'Phinney <matthew@...> wrote
> > (on Monday, 21 July 2008, 12:37 PM -0400):
> >> -- duyhung <duyhung852002@...> wrote
> >> (on Monday, 21 July 2008, 05:10 AM -0700):
> >> > Yes, I was using the old incubator version. Thanks Matthew, you saved
> >> my day.
> >>
> >> Glad I could help!
> >>
> >> > Btw, I'm wondering how can you set the password field
> >> > (validationtextbox in my case) to be asterisk input as I haven't seen
> >> > anyway to do that? I did read the ZF doc though.
> >>
> >> You know, really not sure. There isn't a dijit for password fields to my
> >> knowledge. I'll ask on the #dojo IRC channel -- you might want to do the
> >> same.
> >
> > It appears that you have two possibilities:
> >
> >   * Create an element that extends ValidationTextBox or TextBox and
> >     which sets the 'type' dijit param to 'password'. (This will be the
> >     route I will officially take)
> >   * Alternately, pass the 'type' dijit parameter with the value
> >     'password' to either a TextBox or ValidationTextBox element. (You
> >     can do this _now_.)
> >
> > --
> > Matthew Weier O'Phinney
> > Software Architect       | matthew@...
> > Zend Framework           | http://framework.zend.com/
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Steps-to-integrating-Dojo-with-Zend-Framework--tp18561545p18587454.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>

--
Matthew Weier O'Phinney
Software Architect       | matthew@...
Zend Framework           | http://framework.zend.com/
LightInTheBox - Buy quality products at wholesale price