Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Ajax::observeField
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Davide  
View profile  
 More options Apr 23 2008, 9:13 am
From: "Davide" <d...@linux.it>
Date: Wed, 23 Apr 2008 15:13:10 +0200 (CEST)
Local: Wed, Apr 23 2008 9:13 am
Subject: Ajax::observeField
Hello everybody

I'm trying to use the method in subject with no result. CakePHP
1.1.18.

The PHP code in thtml is:

...
echo $html->input("Project/name",array("maxlength"=>"50","class"=>""));
...
echo $ajax->observeField(
               "ProjectName",
               array(
                  "update"=>"web",
                  "url"=>"/projects/webAlias/"
               )
          )?>
...

the rendered code (html) is the following

...
<input name="data[Project][name]"  maxlength="50" class="" value=""
type="text" id="ProjectName" />
...
<script type="text/javascript">
   new Form.Element.Observer('ProjectName', 2,
       function(element, value) {
          new Ajax.Updater('web','/projects/webAlias/', {
              asynchronous:true, evalScripts:true,
              parameters:Form.Element.serialize('ProjectName'),
              requestHeaders:['X-Update', 'web']}
          )
       }
   )
</script>

everything "works" except that it's returned to me that is missing
argument 1 for the controller action.

Maybe I'm missing some parameter to the observeField function.

Bye
Davide

--
Live life like you're gonna die. Because you're gonna.
                                            William Shatner


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Davide  
View profile  
(1 user)  More options Apr 23 2008, 9:45 am
From: "Davide" <d...@linux.it>
Date: Wed, 23 Apr 2008 15:45:03 +0200 (CEST)
Local: Wed, Apr 23 2008 9:45 am
Subject: Re: Ajax::observeField

Davide wrote:
> ...
> everything "works" except that it's returned to me that is missing
> argument 1 for the controller action.

Solved at moment making the function argument as optional and testing
for the existence of $this->data["Project"]["name"]

thank and bye
davide

--
Live life like you're gonna die. Because you're gonna.
                                            William Shatner


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Davide  
View profile  
 More options Apr 23 2008, 11:37 am
From: "Davide" <d...@linux.it>
Date: Wed, 23 Apr 2008 17:37:53 +0200 (CEST)
Local: Wed, Apr 23 2008 11:37 am
Subject: Re: Ajax::observeField
A strange thing regarding this topic.

I can't understand where's the problem.

Everytime I call the method with the observeField, all my Session data
is lost and so I'm disconnected.

It's the first time I'm using Ajax+AjaxHelper+Cake, so I could do
something wrong.

When I remove the observeField call, everything is fine.

Here is the code of the methods:

<?php
// app/controllers/projects_controller.php
class ProjectsController extends AppController {
...
   function beforeFilter(){
      parent::beforeFilter();
      array_push($this->helpers,"ajax");
   }
...
   function webAlias(){
      if(isset($this->data["Project"]["name"])){
         $this->layout = "ajax";
         $this->autoRender = false;
         echo $this->_webAlias($this->data["Project"]["name"]);
      }
   }

}

?>

<?php
/*
 * /app/app_controller.php
 */
class AppController extends Controller {
...
   function beforeFilter(){
      parent::beforeFilter();

      $aro = ALL;
      if($this->Session->check(ID)){
         $aro = $this->Session->read(ARO);
      }

      if(isset($this->params["controller"]) &&
isset($this->params["action"])){
         if($this->checkAccess($this->params["controller"],$this->params["action"],$ aro)){
         }else{
            $this->redirect("/pages/denied");
            exit;
         }
      }
   }

   /**
    * return a web alias starting from a provied string
    *
    * @param $string the provided string to be parsed
    * @return the translated string
    */
   function _webAlias($string){
      $ret = trim(strtolower($string));
      $ret = preg_replace("/[ ]/","-",$ret);
      $ret = preg_replace("/^[-]+/","",$ret);
      $ret = preg_replace("/[-]+\$/","",$ret);
      $ret = preg_replace("/[^a-z0-9-]/","",$ret);
      return $ret;
   }
...

}

?>
--
Live life like you're gonna die. Because you're gonna.
                                            William Shatner

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Hartjes  
View profile  
 More options Apr 23 2008, 11:42 am
From: "Chris Hartjes" <chart...@gmail.com>
Date: Wed, 23 Apr 2008 11:42:09 -0400
Local: Wed, Apr 23 2008 11:42 am
Subject: Re: Ajax::observeField

On Wed, Apr 23, 2008 at 11:37 AM, Davide <d...@linux.it> wrote:

>  A strange thing regarding this topic.

>  I can't understand where's the problem.

>  Everytime I call the method with the observeField, all my Session data
>  is lost and so I'm disconnected.

You might have to change some stuff in your config/core.php file.

Look for Session.checkAgent

Often you have do

Configure::write('Session.checkAgent', false);

to preserve sessions when using Ajax

Hope that helps.

--
Chris Hartjes
Internet Loudmouth
Motto for 2008: "Moving from herding elephants to handling snakes..."
@TheKeyBoard: http://www.littlehart.net/atthekeyboard


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Davide  
View profile  
 More options Apr 23 2008, 11:52 am
From: "Davide" <d...@linux.it>
Date: Wed, 23 Apr 2008 17:52:17 +0200 (CEST)
Local: Wed, Apr 23 2008 11:52 am
Subject: Re: Ajax::observeField

Chris Hartjes wrote:
> You might have to change some stuff in your config/core.php file.

> Look for Session.checkAgent

> Often you have do

> Configure::write('Session.checkAgent', false);

> to preserve sessions when using Ajax

Session.checkAgent is not defined in my core.php. I tried defining it

define("Session.checkAgent",false);

and call the Configure::write

  function webAlias(){
      if(isset($this->data["Project"]["name"])){
         Configure::write('Session.checkAgent', false);
         $this->layout = "ajax";
         $this->autoRender = false;
         echo $this->_webAlias($this->data["Project"]["name"]);
      }
   }

But none of them worked.

Some other ideas? Cake version 1.1.18.

--
Live life like you're gonna die. Because you're gonna.
                                            William Shatner


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Hartjes  
View profile  
 More options Apr 23 2008, 11:55 am
From: "Chris Hartjes" <chart...@gmail.com>
Date: Wed, 23 Apr 2008 11:55:00 -0400
Subject: Re: Ajax::observeField

On Wed, Apr 23, 2008 at 11:52 AM, Davide <d...@linux.it> wrote:
>  Some other ideas? Cake version 1.1.18.

D'oh -- that stuff I posted is Cake 1.2 specific.

I don't use Cake 1.1 at all, so can't help you there.

--
Chris Hartjes
Internet Loudmouth
Motto for 2008: "Moving from herding elephants to handling snakes..."
@TheKeyBoard: http://www.littlehart.net/atthekeyboard


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Davide  
View profile  
 More options Apr 24 2008, 5:22 am
From: "Davide" <d...@linux.it>
Date: Thu, 24 Apr 2008 11:22:13 +0200 (CEST)
Local: Thurs, Apr 24 2008 5:22 am
Subject: Re: Ajax::observeField

Chris Hartjes wrote:
> D'oh -- that stuff I posted is Cake 1.2 specific.

> I don't use Cake 1.1 at all, so can't help you there.

Ok Chris but you gave me a hint. So searching in the core code
(session.php) I saw three points where Session.checkAgent is
present. The only way I found (puttin some debug messages) for setting
this parameter was putting the Configure::write inside the
bootstrap.php, cause inside the core.php it seems to be ignored, or
maybe the core.php is read after the session.php; I've not got deeper
the question.

I've also tried to put it to false editing the core libs/configure.php
the only Session.checkAgent (line 340) but it seems to be ignored or
to be not enough for the problem.

Finally, I've solved, after restoring the old situation, making the
CAKE_SECURITY=medium in the app core.php (it was "high" before). Now
everything is working out right.

Thanks a lot
Bye
Davide

--
Live life like you're gonna die. Because you're gonna.
                                            William Shatner


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google