Re: having big trouble with evalJSON() - am I really at war with it?

2009-07-23 Thread Max Weißböck (info)

Thanks so much, you really saved my day!

Am 23.07.2009 um 17:18 schrieb Sven Homburg:


dont use the evanJSON() function, its not needed anymore

with regards
Sven Homburg
Founder of the Chenille Kit Project
http://www.chenillekit.org





2009/7/23 Max Weißböck (info) :

Based on the example from Hugo Palma (see
http://markmail.org/message/4bdwo2yrx6tavdgh)
I implemented a dependend checkbox.

Event handling is fine, but I lost hours finding out while
response.evalJSON() fails and I still have no clue...

Im always getting this erreor;
Error communication with the server: Result of expression
'response.evalJSON' [undefined] is not a function.

Looks like evalJSON ist not defined (I'm not a JavaScript guy at  
all)


How do I import the js library that includes the evalJSON function?  
I tried

everithing I can think of and this is my
current js import

@IncludeJavaScriptLibrary( { "context:js/Chenillekit.js",
"context:js/RESelection.js", "${tapestry.scriptaculous}/ 
prototype.js" })

public class RealEstateCreate {

Any help is VERY welcome, as I'm at a dead end now


Thanks, Max


This are the js, tml and class files

-- RESelection.js -

function onCompleteChangeReSubType(response) {
   selectElement = $('resubtype');
   Tapestry.debug(response);
   Tapestry.debug("1");
   responseJSON = response.evalJSON();
   Tapestry.debug("2");

   while (selectElement.options.length > 0) {
   selectElement.options[0] = null;
   }

   for (index = 0; index < responseJSON.length; index++) {
   selectElement.options[index] = new Option(responseJSON
   [index].label, responseJSON [index].value);
   }

   Tapestry.ElementEffect.highlight($("resubtype"));
}


class---





- tml RealEstateCreate.tml 

http://tapestry.apache.org/schema/tapestry_5_1_0.xsd";
 xmlns:p="tapestry:parameter">

   

   

   
   
   
   

   
   

   
   

   
   
   
   
   
   

   
   
   

   

   
   
   ${message}
   
   

   
   
   
   
   




 class  RealEstateCreate.java --


package net.weissboeck.gimmo.pages.realestate;

import java.util.List;

import net.weissboeck.gimmo.annotations.InjectSelectionModel;
import net.weissboeck.gimmo.beans.WebUser;
import net.weissboeck.gimmo.entities.Agent;
import net.weissboeck.gimmo.entities.RESubType;
import net.weissboeck.gimmo.entities.REType;
import net.weissboeck.gimmo.entities.RealEstate;
import net.weissboeck.gimmo.services.DataService;
import net.weissboeck.gimmo.services.RealEstateService;
import net.weissboeck.gimmo.services.UserService;
import net.weissboeck.gimmo.util.ExceptionParser;

import org.apache.tapestry5.PersistenceConstants;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Mixins;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.corelib.components.Form;
import org.apache.tapestry5.corelib.components.Select;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.json.JSONArray;
import org.apache.tapestry5.json.JSONObject;
import org.chenillekit.access.annotations.Restricted;
import org.slf4j.Logger;


@Restricted(groups = { "AGENT" })
@IncludeJavaScriptLibrary( { "context:js/Chenillekit.js",
"context:js/RESelection.js", "${tapestry.scriptaculous}/ 
prototype.js" })

public class RealEstateCreate {

   @Inject
   private Logger logger;

   @SessionState
   private WebUser webUser;

   @Component
   private Form form;

   @Persist
   @Property
   private RealEstate realEstate;

   @SuppressWarnings("unused")
   @Property
   @Persist(PersistenceConstants.FLASH)
   private String message;

   @InjectPage
   private RealEstateEdit editPage;

   @Inject
   private RealEstateService realEstateService;

   @Inject
   private DataService dataService;

   @Inject
   private UserService userService;

   @InjectSelectionModel(labelField = "name", idField = "oid")
   private List reTypes;

   @InjectSelectionModel(labelField = "name", idField = "oid")
   private List reSubTypes;

   @Component(parameters = {"event=change",
"onCompleteCallback=literal:onCompleteChangeReSubType"})
   @Mixins({"ck/OnEvent"})
   private Select reType;



   @Log
   @OnEvent(component="reType", value="change")
   public JSONArray onChangeRETypeEvent(String value) {
   JSONArray jsonArray = new JSONArray();

   List subTypes =
dataService 
.ge

Re: having big trouble with evalJSON() - am I really at war with it?

2009-07-23 Thread Sven Homburg
dont use the evanJSON() function, its not needed anymore

with regards
Sven Homburg
Founder of the Chenille Kit Project
http://www.chenillekit.org





2009/7/23 Max Weißböck (info) :
> Based on the example from Hugo Palma (see
> http://markmail.org/message/4bdwo2yrx6tavdgh)
> I implemented a dependend checkbox.
>
> Event handling is fine, but I lost hours finding out while
> response.evalJSON() fails and I still have no clue...
>
> Im always getting this erreor;
> Error communication with the server: Result of expression
> 'response.evalJSON' [undefined] is not a function.
>
> Looks like evalJSON ist not defined (I'm not a JavaScript guy at all)
>
> How do I import the js library that includes the evalJSON function? I tried
> everithing I can think of and this is my
> current js import
>
> @IncludeJavaScriptLibrary( { "context:js/Chenillekit.js",
> "context:js/RESelection.js", "${tapestry.scriptaculous}/prototype.js" })
> public class RealEstateCreate {
>
> Any help is VERY welcome, as I'm at a dead end now
>
>
> Thanks, Max
>
>
> This are the js, tml and class files
>
> -- RESelection.js -
>
> function onCompleteChangeReSubType(response) {
>    selectElement = $('resubtype');
>    Tapestry.debug(response);
>    Tapestry.debug("1");
>    responseJSON = response.evalJSON();
>    Tapestry.debug("2");
>
>    while (selectElement.options.length > 0) {
>        selectElement.options[0] = null;
>    }
>
>    for (index = 0; index < responseJSON.length; index++) {
>        selectElement.options[index] = new Option(responseJSON
>                        [index].label, responseJSON [index].value);
>    }
>
>    Tapestry.ElementEffect.highlight($("resubtype"));
> }
>
>
> class---
>
>
>
>
>
> - tml RealEstateCreate.tml 
>
>  sidebarTitle="message:sidebarTitle"
>      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd";
>      xmlns:p="tapestry:parameter">
>
>        
>
>            
>
>                
>                        
>                 validate="required"/>
>        
>
>        
>                 value="realestate.retype"
>                                model="reTypesSelectionModel"
> encoder="reTypesValueEncoder" validate="required"/>
>
>                
>                 value="realestate.resubtype"
>                                model="reSubTypesSelectionModel"
> encoder="reSubTypesValueEncoder" validate="required"/>
>
>        
>                
>                
>                 value="realestate.description"/>
>            
>        
>
>        
>            
>        
>
>        
>
>        
>                
>                        ${message}
>                
>        
>
>        
>                
>                        
>                
>        
>
> 
>
>
>  class  RealEstateCreate.java --
>
>
> package net.weissboeck.gimmo.pages.realestate;
>
> import java.util.List;
>
> import net.weissboeck.gimmo.annotations.InjectSelectionModel;
> import net.weissboeck.gimmo.beans.WebUser;
> import net.weissboeck.gimmo.entities.Agent;
> import net.weissboeck.gimmo.entities.RESubType;
> import net.weissboeck.gimmo.entities.REType;
> import net.weissboeck.gimmo.entities.RealEstate;
> import net.weissboeck.gimmo.services.DataService;
> import net.weissboeck.gimmo.services.RealEstateService;
> import net.weissboeck.gimmo.services.UserService;
> import net.weissboeck.gimmo.util.ExceptionParser;
>
> import org.apache.tapestry5.PersistenceConstants;
> import org.apache.tapestry5.annotations.Component;
> import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
> import org.apache.tapestry5.annotations.InjectPage;
> import org.apache.tapestry5.annotations.Log;
> import org.apache.tapestry5.annotations.Mixins;
> import org.apache.tapestry5.annotations.OnEvent;
> import org.apache.tapestry5.annotations.Persist;
> import org.apache.tapestry5.annotations.Property;
> import org.apache.tapestry5.annotations.SessionState;
> import org.apache.tapestry5.corelib.components.Form;
> import org.apache.tapestry5.corelib.components.Select;
> import org.apache.tapestry5.ioc.annotations.Inject;
> import org.apache.tapestry5.json.JSONArray;
> import org.apache.tapestry5.json.JSONObject;
> import org.chenillekit.access.annotations.Restricted;
> import org.slf4j.Logger;
>
>
> @Restricted(groups = { "AGENT" })
> @IncludeJavaScriptLibrary( { "context:js/Chenillekit.js",
> "context:js/RESelection.js", "${tapestry.scriptaculous}/prototype.js" })
> public class RealEstateCreate {
>
>   �...@inject
>    private Logger logger;
>
>   �...@sessionstate
>    private WebUser webUser;
>
>   �...@component
>    private Form form;
>
>   �...@persist
>   �...@property
>    private RealEstate realEstate;
>
>   �...@suppresswarnings("unused")
>       �...@property
>   �...@persist(PersistenceConstants.FLASH)
>    private String message;
>
>   �...@injectpage
>    private RealEstateEdit editPage;
>
>   �...@inject
>    private RealEstateService realEstateService;
>
>   �...@in

having big trouble with evalJSON() - am I really at war with it?

2009-07-23 Thread Maximilian Weißböck

Based on the example from Hugo Palma (see 
http://markmail.org/message/4bdwo2yrx6tavdgh)
I implemented a dependend checkbox.

Event handling is fine, but I lost hours finding out while  
response.evalJSON() fails and I still have no clue...


Im always getting this erreor;
Error communication with the server: Result of expression  
'response.evalJSON' [undefined] is not a function.


Looks like evalJSON ist not defined (I'm not a JavaScript guy at  
all)


How do I import the js library that includes the evalJSON function? I  
tried everithing I can think of and this is my

current js import

@IncludeJavaScriptLibrary( { "context:js/Chenillekit.js", "context:js/ 
RESelection.js", "${tapestry.scriptaculous}/prototype.js" })

public class RealEstateCreate {

Any help is VERY welcome, as I'm at a dead end now


Thanks, Max


This are the js, tml and class files

-- RESelection.js -

function onCompleteChangeReSubType(response) {
selectElement = $('resubtype');
Tapestry.debug(response);
Tapestry.debug("1");
responseJSON = response.evalJSON();
Tapestry.debug("2");

while (selectElement.options.length > 0) {
selectElement.options[0] = null;
}

for (index = 0; index < responseJSON.length; index++) {
selectElement.options[index] = new Option(responseJSON
[index].label, responseJSON [index].value);
}

Tapestry.ElementEffect.highlight($("resubtype"));
}


class---





- tml RealEstateCreate.tml 


  xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd";
  xmlns:p="tapestry:parameter">







	validate="required"/>




model="reTypesSelectionModel" encoder="reTypesValueEncoder"  
validate="required"/>



model="reSubTypesSelectionModel" encoder="reSubTypesValueEncoder"  
validate="required"/>





value="realestate.description"/>












${message}












 class  RealEstateCreate.java --


package net.weissboeck.gimmo.pages.realestate;

import java.util.List;

import net.weissboeck.gimmo.annotations.InjectSelectionModel;
import net.weissboeck.gimmo.beans.WebUser;
import net.weissboeck.gimmo.entities.Agent;
import net.weissboeck.gimmo.entities.RESubType;
import net.weissboeck.gimmo.entities.REType;
import net.weissboeck.gimmo.entities.RealEstate;
import net.weissboeck.gimmo.services.DataService;
import net.weissboeck.gimmo.services.RealEstateService;
import net.weissboeck.gimmo.services.UserService;
import net.weissboeck.gimmo.util.ExceptionParser;

import org.apache.tapestry5.PersistenceConstants;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Mixins;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.corelib.components.Form;
import org.apache.tapestry5.corelib.components.Select;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.json.JSONArray;
import org.apache.tapestry5.json.JSONObject;
import org.chenillekit.access.annotations.Restricted;
import org.slf4j.Logger;


@Restricted(groups = { "AGENT" })
@IncludeJavaScriptLibrary( { "context:js/Chenillekit.js", "context:js/ 
RESelection.js", "${tapestry.scriptaculous}/prototype.js" })

public class RealEstateCreate {

@Inject
private Logger logger;

@SessionState
private WebUser webUser;

@Component
private Form form;

@Persist
@Property
private RealEstate realEstate;

@SuppressWarnings("unused")
@Property
@Persist(PersistenceConstants.FLASH)
private String message;

@InjectPage
private RealEstateEdit editPage;

@Inject
private RealEstateService realEstateService;

@Inject
private DataService dataService;

@Inject
private UserService userService;

@InjectSelectionModel(labelField = "name", idField = "oid")
private List reTypes;

@InjectSelectionModel(labelField = "name", idField = "oid")
private List reSubTypes;

@Component(parameters = {"event=change",  
"onCompleteCallback=literal:onCompleteChangeReSubType"})

@Mixins({"ck/OnEvent"})
private Select reType;



@Log
@OnEvent(component="reType", value="change")
public JSONArray onChangeRETypeEvent(String value)

having big trouble with evalJSON() - am I really at war with it?

2009-07-23 Thread info

Based on the example from Hugo Palma (see 
http://markmail.org/message/4bdwo2yrx6tavdgh)
I implemented a dependend checkbox.

Event handling is fine, but I lost hours finding out while  
response.evalJSON() fails and I still have no clue...


Im always getting this erreor;
Error communication with the server: Result of expression  
'response.evalJSON' [undefined] is not a function.


Looks like evalJSON ist not defined (I'm not a JavaScript guy at  
all)


How do I import the js library that includes the evalJSON function? I  
tried everithing I can think of and this is my

current js import

@IncludeJavaScriptLibrary( { "context:js/Chenillekit.js", "context:js/ 
RESelection.js", "${tapestry.scriptaculous}/prototype.js" })

public class RealEstateCreate {

Any help is VERY welcome, as I'm at a dead end now


Thanks, Max


This are the js, tml and class files

-- RESelection.js -

function onCompleteChangeReSubType(response) {
selectElement = $('resubtype');
Tapestry.debug(response);
Tapestry.debug("1");
responseJSON = response.evalJSON();
Tapestry.debug("2");

while (selectElement.options.length > 0) {
selectElement.options[0] = null;
}

for (index = 0; index < responseJSON.length; index++) {
selectElement.options[index] = new Option(responseJSON
[index].label, responseJSON [index].value);
}

Tapestry.ElementEffect.highlight($("resubtype"));
}


class---





- tml RealEstateCreate.tml 


  xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd";
  xmlns:p="tapestry:parameter">







	validate="required"/>




model="reTypesSelectionModel" encoder="reTypesValueEncoder"  
validate="required"/>



model="reSubTypesSelectionModel" encoder="reSubTypesValueEncoder"  
validate="required"/>





value="realestate.description"/>












${message}












 class  RealEstateCreate.java --


package net.weissboeck.gimmo.pages.realestate;

import java.util.List;

import net.weissboeck.gimmo.annotations.InjectSelectionModel;
import net.weissboeck.gimmo.beans.WebUser;
import net.weissboeck.gimmo.entities.Agent;
import net.weissboeck.gimmo.entities.RESubType;
import net.weissboeck.gimmo.entities.REType;
import net.weissboeck.gimmo.entities.RealEstate;
import net.weissboeck.gimmo.services.DataService;
import net.weissboeck.gimmo.services.RealEstateService;
import net.weissboeck.gimmo.services.UserService;
import net.weissboeck.gimmo.util.ExceptionParser;

import org.apache.tapestry5.PersistenceConstants;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Mixins;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.corelib.components.Form;
import org.apache.tapestry5.corelib.components.Select;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.json.JSONArray;
import org.apache.tapestry5.json.JSONObject;
import org.chenillekit.access.annotations.Restricted;
import org.slf4j.Logger;


@Restricted(groups = { "AGENT" })
@IncludeJavaScriptLibrary( { "context:js/Chenillekit.js", "context:js/ 
RESelection.js", "${tapestry.scriptaculous}/prototype.js" })

public class RealEstateCreate {

@Inject
private Logger logger;

@SessionState
private WebUser webUser;

@Component
private Form form;

@Persist
@Property
private RealEstate realEstate;

@SuppressWarnings("unused")
@Property
@Persist(PersistenceConstants.FLASH)
private String message;

@InjectPage
private RealEstateEdit editPage;

@Inject
private RealEstateService realEstateService;

@Inject
private DataService dataService;

@Inject
private UserService userService;

@InjectSelectionModel(labelField = "name", idField = "oid")
private List reTypes;

@InjectSelectionModel(labelField = "name", idField = "oid")
private List reSubTypes;

@Component(parameters = {"event=change",  
"onCompleteCallback=literal:onCompleteChangeReSubType"})

@Mixins({"ck/OnEvent"})
private Select reType;



@Log
@OnEvent(component="reType", value="change")
public JSONArray onChangeRETypeEvent(String value)