Re: Difference between renderSupport.addScript and JSON addInit(function, JSON Object)

2012-06-20 Thread Steve Eynon
in address.js remove the last call to loadAddresse. i.e. just have

Tapestry.Initializer.loadAddresse = function loadAddresse(jsonObject){
...
}

it is probably that last surplus : loadAddresse(jsonObject); that
caused the JS error ('cos there is no global function called
loadAddresse) which then disabled JavaScript for the rest of the page
load.

Steve.




On 20 June 2012 15:56, baptiste  wrote:
> It doesn't work for me.
>
> In java :
>   @IncludeJavaScriptLibrary({ "context:static/javascript/address.js" })
>
>   @Environmental
>    private RenderSupport renderSupport;
>
>    @BeginRender
>    void addJsLibs() {
>        log.debug("BEGIN addJsLibs");
>        JSONObject jsonObject = new JSONObject();
>        jsonObject.put("m1", messages.get("new_delivery_address"));
>        jsonObject.put("m2", messages.get("js.error.address.empty"));
>        jsonObject.put("m3", messages.get("js.error.receiving.person.empty"));
>        jsonObject.put("m4", messages.get("js.error.street.empty"));
>        jsonObject.put("m5", messages.get("js.error.house.empty"));
>        jsonObject.put("m6", messages.get("js.error.postcode.empty"));
>        jsonObject.put("m7", messages.get("js.error.postcode.wrong"));
>        jsonObject.put("m8", messages.get("js.error.city.empty"));
>        jsonObject.put("m9", 
> messages.get("js.error.special.chars.not_accepted"));
>        jsonObject.put("m10", messages.get("js.error.floor.empty"));
>        jsonObject.put("m11", messages.get("js.error.floor.wrong"));
>        jsonObject.put("m12", messages.get("js.error.elevator.empty"));
>        renderSupport.addInit("loadAddresse", jsonObject);
>        log.debug("END addJsLibs");
>    }
>
> in address.js:
> Tapestry.Initializer.loadAddresse = function loadAddresse(jsonObject){
> ...
> }
> loadAddresse(jsonObject);
>
> In browser console:
> loadAddresse is not defined
> and method in loadAddresse can never be called
>
> --
> View this message in context: 
> http://tapestry.1045711.n5.nabble.com/Difference-between-renderSupport-addScript-and-JSON-addInit-function-JSON-Object-tp5105620p5713987.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Difference between renderSupport.addScript and JSON addInit(function, JSON Object)

2012-06-20 Thread baptiste
It doesn't work for me.

In java : 
   @IncludeJavaScriptLibrary({ "context:static/javascript/address.js" })
  
   @Environmental
private RenderSupport renderSupport;

@BeginRender
void addJsLibs() {
log.debug("BEGIN addJsLibs");
JSONObject jsonObject = new JSONObject();
jsonObject.put("m1", messages.get("new_delivery_address"));
jsonObject.put("m2", messages.get("js.error.address.empty"));
jsonObject.put("m3", messages.get("js.error.receiving.person.empty"));
jsonObject.put("m4", messages.get("js.error.street.empty"));
jsonObject.put("m5", messages.get("js.error.house.empty"));
jsonObject.put("m6", messages.get("js.error.postcode.empty"));
jsonObject.put("m7", messages.get("js.error.postcode.wrong"));
jsonObject.put("m8", messages.get("js.error.city.empty"));
jsonObject.put("m9", 
messages.get("js.error.special.chars.not_accepted"));
jsonObject.put("m10", messages.get("js.error.floor.empty"));
jsonObject.put("m11", messages.get("js.error.floor.wrong"));
jsonObject.put("m12", messages.get("js.error.elevator.empty"));
renderSupport.addInit("loadAddresse", jsonObject);
log.debug("END addJsLibs");
}

in address.js:
Tapestry.Initializer.loadAddresse = function loadAddresse(jsonObject){
...
}
loadAddresse(jsonObject);

In browser console:
loadAddresse is not defined
and method in loadAddresse can never be called

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Difference-between-renderSupport-addScript-and-JSON-addInit-function-JSON-Object-tp5105620p5713987.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Difference between renderSupport.addScript and JSON addInit(function, JSON Object)

2012-01-12 Thread Javix
I found why it didn't work. I just replaced:

Tapestry.Initializer.load = function loadPass(jsonObject){  

}

with 

Tapestry.Initializer.loadPass = function loadPass(jsonObject){  
...
}

I believed that 'load' was a maethod to call on Tapestry.Initializer
object(unfortunately T API says nothing about that).
Of course I removed the 'if' check for 'error' variable in the Java class,
if not, the function is never loaded.
Cheers. And thank you for your time :)

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Difference-between-renderSupport-addScript-and-JSON-addInit-function-JSON-Object-tp5105620p5139660.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Difference between renderSupport.addScript and JSON addInit(function, JSON Object)

2012-01-06 Thread Thiago H. de Paula Figueiredo

On Fri, 06 Jan 2012 13:48:58 -0200, Javix  wrote:


One more question:
How to trigger the exectution of js function.


Just call it.


For exmaple, before the code
was like that directly n the tml page:



Some hard-coded 
meessage



So I tried to apply your technics, but the js function is never loaded (I
have no errors displayed when submitting the form):


Loaded or invoked? They're very different things. Have you tried using  
FireBug or some similar tool to put a breakpoint in your function? By the  
way, I don't really understood what you're asking.


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Difference between renderSupport.addScript and JSON addInit(function, JSON Object)

2012-01-06 Thread Javix
One more question:
How to trigger the exectution of js function. For exmaple, before the code
was like that directly n the tml page:



Some hard-coded 
meessage



So I tried to apply your technics, but the js function is never loaded (I
have no errors displayed when submitting the form):
@IncludeJavaScriptLibrary(value = { "context:/static/javascript/password.js"
})
public class ForgottenPassword {
...
@Property
private boolean error;

@BeginRender
void addJsLibs() {
if (error) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("m1", messages.get("js.error.password.epmpty"));
jsonObject.put("m2",
messages.get("js.error.confirmed_password.empty"));
jsonObject.put("m3", messages.get("js.error.password.not_matched"));
jsonObject.put("m4", messages.get("js.error.email.empty"));
jsonObject.put("m5", messages.get("js.error.email.wrong")); 


renderSupport.addInit("loadPass", jsonObject);
}
}
...
}
And in JS file password.js:

Tapestry.Initializer.load = function loadPass(jsonObject){
..
passError.html(jsonObject.m1);
...
}
loadPass(jsonObject);

Why?






--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Difference-between-renderSupport-addScript-and-JSON-addInit-function-JSON-Object-tp5105620p5125897.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Difference between renderSupport.addScript and JSON addInit(function, JSON Object)

2012-01-04 Thread Javix
Finally I got it working by adding as you told:

Tapestry.Initializer.load = function load(jsonObject){
..
errorText.text(jsonObject.m1)

}

and ot in the very begining of the call:

jQuery(document).bind(Tapestry.ZONE_UPDATED_EVENT, function(e){ 
//load(m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12);
load(jsonObject);
});
It works, THANK YOU!

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Difference-between-renderSupport-addScript-and-JSON-addInit-function-JSON-Object-tp5105620p5119608.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Difference between renderSupport.addScript and JSON addInit(function, JSON Object)

2012-01-04 Thread Javix
It didn't work:

Oups ... org.apache.tapestry5.runtime.ComponentEventException: A component
event handler method returned the value
MultiZoneUpdate[{page=org.apache.tapestry5.corelib.components.Zone@1799a64, 

May it's because in the javascript file the call to the load fucntion is
made lie that:

jQuery(document).bind(Tapestry.ZONE_UPDATED_EVENT, function(e){ 
//load(m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12);
load(jsonObject);
});

...
Tapestry.Initializer.load = function load(jsonObject){
//function load(m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12){
errorText.text(jsonObject.m1)
...
}

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Difference-between-renderSupport-addScript-and-JSON-addInit-function-JSON-Object-tp5105620p5119428.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Difference between renderSupport.addScript and JSON addInit(function, JSON Object)

2012-01-03 Thread Thiago H. de Paula Figueiredo

On Wed, 28 Dec 2011 14:40:12 -0200, Javix  wrote:


In javascript, I just replaced arguments by jsonObject:

function load(jsonObject){
...
//acces to the variable in JSON
errorText.text(jsonObject.m2)
}

Why in case of JSON it DOES NOT WORK ?


From the addInit() JavaDoc, specifically the first parameter:

functionName  the name of the function (on the client-side  
Tapestry.Initializer object) to invoke.


addInit() just invokes functions that are part of the Tapestry.Initializer  
object. Try this instead:


Tapestry.Initializer.load = function(jsonObject){
 ...
 //acces to the variable in JSON
 errorText.text(jsonObject.m2)
}

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org