Re: Javascript module isn't generating css asset url

2022-04-15 Thread Ben Weidig
Hi George,

I can't help with a "good" solution, only what we did to get the Monaco
Editor running which loads css/js by itself.

IIRC the underlying problem is that JS using require() builds the "wrong"
URL for the requested asset/tapestry on the client-side.
Tapestry expects modules to be in META-INF/modules and anything else in
META-INF/assets.
That's why they need to be split up accordingly, and we intercept any
requests to the "wrong" folder and fix them.

I know it's quite hacky, but when I wrote it in the past I didn't know any
better, and it worked for our problem.
But maybe there should be an easier way to support loading related files
for JS modules.

Gist for readability:
https://gist.github.com/benweidig/aba58e79be2850f55ab3fb14424ff311

public class MonacoEditorModule {

private static final Pattern CSS_PATTERN =
Pattern.compile("^/modules(\\.gz)?/monaco/(.+\\.css)$");
private static final Pattern JS_PATTERN =
Pattern.compile("^/modules(\\.gz)?/monaco/vs/(.+\\.js)$");

public static void
contributeRequestHandler(OrderedConfiguration conf,
ResourceStreamer streamer) {

conf.add("monaco-assets-redirect-request-filter", (request,
response, handler) -> {
var matcher = cssPattern.matcher(request.getPath());
if (matcher.matches() == false) {
return handler.service(request, response);
}

var resource = new
ClasspathResource("META-INF/assets/backend/monaco/" + matcher.group(2));
streamer.streamResource(resource, //
"",

EnumSet.of(ResourceStreamer.Options.OMIT_EXPIRATION));
return true;
});

conf.add("monaco-module-redirect-request-filter", (request,
response, handler) -> {
var matcher = jsPattern.matcher(request.getPath());

if (matcher.matches() == false) {
return handler.service(request, response);
}

var resource = new
ClasspathResource("META-INF/modules/monaco/0.26.1/" + matcher.group(2));

request.setAttribute(TapestryConstants.DISABLE_JAVASCRIPT_MINIMIZATION,
Boolean.TRUE);

streamer.streamResource(resource, //
"z",

EnumSet.of(ResourceStreamer.Options.OMIT_EXPIRATION));
return true;
});
}
}

Cheers
Ben

On Thu, Apr 14, 2022 at 11:04 PM George Christman 
wrote:

> Hi, I upgraded to Tapestry 5.8.1 and I moved all my js, css and modules to
> the webapp directory. I have a ckeditor module that is trying to load some
> ckeditor css and image files. In older versions of tapestry I resolved this
> with ClasspathAssetAliasManager, but that seems to be deprecated and no
> longer functional. "configuration.add("ck", "META-INF/modules/vendor");".
> My package structure is webapp/modules/editor.js
> webapp/modules/vendor/ckeditor
>
> My editor.js file looks like this.
>
> requirejs.config({
> shim: {
> 'ckeditor-jquery': ['jquery', 'ckeditor-core']
> },
> paths: {
> 'ckeditor-core': 'vendor/ckeditor/ckeditor',
> 'ckeditor-jquery': 'vendor/ckeditor/adapters/jquery'
> }
> });
> define(["jquery", "ckeditor-jquery"], function($) {
>
> init = function(spec) {
> $('#' + spec.id).ckeditor();
> };
>
> return init;
> });
>
> How is this achieved in 5.8?
> --
>
> George Christman
>
>
>
> This e-mail may contain confidential, proprietary information on Zigster.
> It is intended solely for the name recipient(s) listed above and should be
> maintained in strictest confidence. If you are not the intended recipient,
> you are hereby notified that any disclosure, copying, distribution, or use
> of the information contained herein (including any reliance thereon) is
> STRICTLY PROHIBITED. If you have received this e-mail in error, please
> immediately notify the sender and delete this information from your
> computer and destroy any related paper copies. Unless otherwise expressly
> stated in the text of the e-mail, the addition of a typed name or initials
> to this e-mail does not (i) evidence an intent to sign the e-mail, or (ii)
> constitute either (a) signature or (b) consent to use electronic records or
> signatures in place of a writing or a handwritten signature.
>


Javascript module isn't generating css asset url

2022-04-14 Thread George Christman
Hi, I upgraded to Tapestry 5.8.1 and I moved all my js, css and modules to
the webapp directory. I have a ckeditor module that is trying to load some
ckeditor css and image files. In older versions of tapestry I resolved this
with ClasspathAssetAliasManager, but that seems to be deprecated and no
longer functional. "configuration.add("ck", "META-INF/modules/vendor");".
My package structure is webapp/modules/editor.js
webapp/modules/vendor/ckeditor

My editor.js file looks like this.

requirejs.config({
shim: {
'ckeditor-jquery': ['jquery', 'ckeditor-core']
},
paths: {
'ckeditor-core': 'vendor/ckeditor/ckeditor',
'ckeditor-jquery': 'vendor/ckeditor/adapters/jquery'
}
});
define(["jquery", "ckeditor-jquery"], function($) {

init = function(spec) {
$('#' + spec.id).ckeditor();
};

return init;
});

How is this achieved in 5.8?
-- 

George Christman



This e-mail may contain confidential, proprietary information on Zigster.
It is intended solely for the name recipient(s) listed above and should be
maintained in strictest confidence. If you are not the intended recipient,
you are hereby notified that any disclosure, copying, distribution, or use
of the information contained herein (including any reliance thereon) is
STRICTLY PROHIBITED. If you have received this e-mail in error, please
immediately notify the sender and delete this information from your
computer and destroy any related paper copies. Unless otherwise expressly
stated in the text of the e-mail, the addition of a typed name or initials
to this e-mail does not (i) evidence an intent to sign the e-mail, or (ii)
constitute either (a) signature or (b) consent to use electronic records or
signatures in place of a writing or a handwritten signature.


Javascript module can't access css / image urls

2022-04-14 Thread George Christman
Hi, I upgraded to Tapestry 5.8.1 and I moved all my js, css and modules to
the webapp directory. I have a ckeditor module that is trying to load some
ckeditor css and image files. In older versions of tapestry I resolved this
with ClasspathAssetAliasManager, but that seems to be deprecated and no
longer functional. "configuration.add("ck", "META-INF/modules/vendor");".
My package structure is webapp/modules/editor.js
webapp/modules/vendor/ckeditor

My editor.js file looks like this.

requirejs.config({
shim: {
'ckeditor-jquery': ['jquery', 'ckeditor-core']
},
paths: {
'ckeditor-core': 'vendor/ckeditor/ckeditor',
'ckeditor-jquery': 'vendor/ckeditor/adapters/jquery'
}
});
define(["jquery", "ckeditor-jquery"], function($) {

init = function(spec) {
$('#' + spec.id).ckeditor();
};

return init;
});

How is this achieved in 5.8?


How to force the loading order of javascript libraries and modules? (jquery, jquery-ui, bootstrap)

2021-04-14 Thread Wilson Velez
I'm upgrading an application from tapestry 5.3.8 to 5.6.2. We use
tapestry-jquery and an old bootstrap. Currently there is a mixin to copy
some text to the clipboard and at the end of the script we inform the user
that the text has been copied with a tooltip.

define([], function() {
  var copyToClipboard = function(spec){
$('#'+spec.id).click(function(){
  var temp$ = $("");
  $("body").append(temp$);
  temp$.val(spec.prefix + $(spec.selector).text() +
spec.suffix).select();
  document.execCommand("copy");
  temp$.remove();
  if (spec.tooltip == "yes") {
var pop = $(this).tooltip({ trigger:"manual", title:"Copied",
placement:"right" });
pop.on('shown.bs.tooltip',function() { setTimeout(function() {
pop.tooltip("hide"); }, 800); });
pop.tooltip("show");
  }
})
  };

  return {
copyToClipboard : copyToClipboard
  };
});

but I'm getting the error "Uncaught Error: no such method 'show' for
tooltip widget instance" because the tooltip that is being used is taken
from jquery-ui and not from bootstrap as it was originally.

I have read that this problem is because the loading order should be
jquery, jquery-ui and bootstrap libraries but the logs in chrome only show
the bootstrap.js:

console.js:104 Loading 11 libraries
console.js:104 Loading library /ims/assets/ctx/z23b9558b/js/bootstrap.js
console.js:104 Loading library
/ims/assets/commons/zc46018e5/components/Menu.js
console.js:104 Loading library
/ims/assets/commons/z5da75a57/mixins/ClickOnce.js

and many other lines about Evaluating and Invoking

And the order in the network tab from the developers tools show
1. jquery.js
2. bootstrap.js (from tapestry core)
3. bootstrap.js (the version from my app)
4. jquery-ui.js

the source html generated has only references to jquery and bootstrap
.




require(["t5/core/pageinit"], function(pi) {
pi([
  "/ims/assets/ctx/z23b9558b/js/bootstrap.js",
  "/ims/assets/commons/zc46018e5/components/Menu.js",
  "/ims/assets/ctx/ze4024904/js/mermaid.min.js",
.

but after loading the page scripts look like this

<script type="text/javascript" charset="utf-8" async=""
data-requirecontext="_" data-requiremodule="t5/core/pageinit"
src="/ims/modules.gz/t5/core/pageinit.js">

...other tapestry scripts



other application scripts.


.finally jquery-ui


and many other scripts


Now, the application has a BootstrapStack (JavascriptStack) that loads the
bootstrap.js and other assets, I even force the loading of the jquery-ui
putting it in the same stack.
Also I created a different Stack for jquery-ui with no luck.
Also, I tried to modify the js module of the mixin to add the modules in
order
define(["jquery", "tjq/vendor/ui/jquery-ui","bootstrap"], function($,
jquery-ui, bootstrap) {
Also I tried defining the BOOTSTRAP_ROOT to see if this changed the order.

What else can I test to achieve the order I need?
Is this happening because of the bootstrap version? because it is a library
and not a module?
is it possible to "encapsulate" my current bootstrap in a javascript module
in order to be loaded as a module?
The final solution would be to change the way we make the feedback to
the user, replacing the tooltip with something else.

Thanks in advance


Re: How to Show a Div using Javascript

2020-10-08 Thread Thiago H. de Paula Figueiredo
On Mon, Oct 5, 2020 at 9:28 AM marwa hussein 
wrote:

> On Mon, Oct 5, 2020, 2:22 PM Thiago H. de Paula Figueiredo <
> thiag...@gmail.com> wrote:
>
> > On Sun, Oct 4, 2020 at 8:37 AM marwa hussein 
> > wrote:
> >
> > > Hi Thiago,
> > >
> >
> > Hello!
> >
> >
> > > Thanks a lot for your reply it works fine but the problem is using this
> > > line of code in beginRender() function shows the "div" when the page is
> > > loaded. but What I want is to show the div after a button is pressed.
> > >
> >
> > In this case, just write the same JavaScript you'd do as if you weren't
> > using Tapestry.
> >
>
>  Do you mean to write a JS function and call it from the onSubmit()
> function and not to use JavaScript support?.
>

No. Write it in a .js file you include in the page. That's what I meant by
writing the same JS as if you weren't using Tapestry.

-- 
Thiago


Re: How to Show a Div using Javascript

2020-10-05 Thread marwa hussein
On Mon, Oct 5, 2020, 2:22 PM Thiago H. de Paula Figueiredo <
thiag...@gmail.com> wrote:

> On Sun, Oct 4, 2020 at 8:37 AM marwa hussein 
> wrote:
>
> > Hi Thiago,
> >
>
> Hello!
>
>
> > Thanks a lot for your reply it works fine but the problem is using this
> > line of code in beginRender() function shows the "div" when the page is
> > loaded. but What I want is to show the div after a button is pressed.
> >
>
> In this case, just write the same JavaScript you'd do as if you weren't
> using Tapestry.
>

 Do you mean to write a JS function and call it from the onSubmit()
function and not to use JavaScript support?.

>
>
> > When I used this line of code in the onSubmit() button function it gives
> > me  "No object of type
> > org.apache.tapestry5.services.javascript.JavaScriptSupport is available
> > from the Environment" exception!!
> >
>
> JavaScriptSupport is only available when the component is being rendered.
> Form submission is not done during rendering, so you get this exception.
>
> --
> Thiago
>


Re: How to Show a Div using Javascript

2020-10-05 Thread Thiago H. de Paula Figueiredo
On Sun, Oct 4, 2020 at 8:37 AM marwa hussein 
wrote:

> Hi Thiago,
>

Hello!


> Thanks a lot for your reply it works fine but the problem is using this
> line of code in beginRender() function shows the "div" when the page is
> loaded. but What I want is to show the div after a button is pressed.
>

In this case, just write the same JavaScript you'd do as if you weren't
using Tapestry.


> When I used this line of code in the onSubmit() button function it gives
> me  "No object of type
> org.apache.tapestry5.services.javascript.JavaScriptSupport is available
> from the Environment" exception!!
>

JavaScriptSupport is only available when the component is being rendered.
Form submission is not done during rendering, so you get this exception.

-- 
Thiago


Re: How to Show a Div using Javascript

2020-10-04 Thread marwa hussein
Hi Thiago,

Thanks a lot for your reply it works fine but the problem is using this
line of code in beginRender() function shows the "div" when the page is
loaded. but What I want is to show the div after a button is pressed.
When I used this line of code in the onSubmit() button function it gives
me  "No object of type
org.apache.tapestry5.services.javascript.JavaScriptSupport is available
from the Environment" exception!!
Could you explain this for me?

Regards,
Marwa

On Sat, Oct 3, 2020 at 10:01 PM Thiago H. de Paula Figueiredo <
thiag...@gmail.com> wrote:

> Hello!
>
> @Inject private JavaScriptSuport javaScriptSupport;
>
> void beginRender() {
>
> javaScriptSupport.addScript("document.getElementById("div1").style.display
> = '';");
> }
>
> On Sat, Oct 3, 2020 at 10:06 AM marwa hussein 
> wrote:
>
> > Hello all,
> > I am new to Tapestry and to Web development in general but I have to
> > implement a simple web application for my research.
> >
> > I use a div that when loading the page I need to hide it, so I use this
> > line:
> >  
> > The div contains "inside it" a grid that will contain some elements
> after a
> > "load" button is pressed.
> > how can I unhide the div again "after pressing the load button"?
> >
> > I know that I could do this with JS Line of code like:
> >  document.getElementById("div1").style.display ="";
> > But how and where can I add a javascrpt line of code directly in my Java
> > class?
> >
> > Thansk in advance
> >
> > --
> >
> >
> >
> > *Marwa Hussein M. TA @ Information Systems Department Faculty of
> Computers
> > & Information Assuit University*
> > 
> >
>
>
> --
> Thiago
>


-- 



*Marwa Hussein M. TA @ Information Systems Department Faculty of Computers
& Information Assuit University*



Re: How to Show a Div using Javascript

2020-10-03 Thread Thiago H. de Paula Figueiredo
Hello!

@Inject private JavaScriptSuport javaScriptSupport;

void beginRender() {

javaScriptSupport.addScript("document.getElementById("div1").style.display
= '';");
}

On Sat, Oct 3, 2020 at 10:06 AM marwa hussein 
wrote:

> Hello all,
> I am new to Tapestry and to Web development in general but I have to
> implement a simple web application for my research.
>
> I use a div that when loading the page I need to hide it, so I use this
> line:
>  
> The div contains "inside it" a grid that will contain some elements after a
> "load" button is pressed.
> how can I unhide the div again "after pressing the load button"?
>
> I know that I could do this with JS Line of code like:
>  document.getElementById("div1").style.display ="";
> But how and where can I add a javascrpt line of code directly in my Java
> class?
>
> Thansk in advance
>
> --
>
>
>
> *Marwa Hussein M. TA @ Information Systems Department Faculty of Computers
> & Information Assuit University*
> 
>


-- 
Thiago


How to Show a Div using Javascript

2020-10-03 Thread marwa hussein
Hello all,
I am new to Tapestry and to Web development in general but I have to
implement a simple web application for my research.

I use a div that when loading the page I need to hide it, so I use this
line:
 
The div contains "inside it" a grid that will contain some elements after a
"load" button is pressed.
how can I unhide the div again "after pressing the load button"?

I know that I could do this with JS Line of code like:
 document.getElementById("div1").style.display ="";
But how and where can I add a javascrpt line of code directly in my Java
class?

Thansk in advance

-- 



*Marwa Hussein M. TA @ Information Systems Department Faculty of Computers
& Information Assuit University*



Re: redirect after javascript ajax call

2020-09-03 Thread Marcel Schepers




Check this and let us know whether it's what you need:
https://tapestry.apache.org/ajax-and-zones.html#AjaxandZones-Invokingserver-sideeventhandlermethodsfromJavaScript

Thank you the link. It did help a bit, but it mainly made me realize 
that my JavaScript/jQuery knowledge is by no means sufficient to solve 
my own problem. I have some homework to do  getting comfortable with 
jQuery.


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



Re: redirect after javascript ajax call

2020-08-28 Thread Thiago H. de Paula Figueiredo
On Fri, Aug 28, 2020 at 2:39 PM Marcel Schepers 
wrote:

> Hello,
>

Hello!


> I am having a bit of a hard time to figure out what the best Tapestry
> way is to do the following. My application's main index page should
> forward the user to another page. I am able to do so by implementing the
> onActivate method and let it return the class of the page to go to. So
> far so good.
>
> What I would like to do now is to run a client-side script that sends
> some screen dimensions to the server _before_ the new page renders its
> response.
>
> A somewhat visual representation of the problem looks like:
> request -> index page -> javascript with a server call -> new page.
>
> Is there an easy way to get this done in Tapestry?
>

Check this and let us know whether it's what you need:
https://tapestry.apache.org/ajax-and-zones.html#AjaxandZones-Invokingserver-sideeventhandlermethodsfromJavaScript



>
> Many thanks in advance!
>
> Best,
> Marcel
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

-- 
Thiago


redirect after javascript ajax call

2020-08-28 Thread Marcel Schepers

Hello,

I am having a bit of a hard time to figure out what the best Tapestry 
way is to do the following. My application's main index page should 
forward the user to another page. I am able to do so by implementing the 
onActivate method and let it return the class of the page to go to. So 
far so good.


What I would like to do now is to run a client-side script that sends 
some screen dimensions to the server _before_ the new page renders its 
response.


A somewhat visual representation of the problem looks like:
request -> index page -> javascript with a server call -> new page.

Is there an easy way to get this done in Tapestry?

Many thanks in advance!

Best,
Marcel

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



Filter for javascript files

2019-11-28 Thread Ric 2000
Dear all,

I want to do a really simple task, but running into problems when doing it
in a Tapestry web application:

The task: replace or remove some content in js files sent to the client.

My approach: I wrote a normal servlet filter with a wrapper for the
HttpServletResponse, which allows to put out the content of the
OutputStream as byte array or string, then replace something in it and
write the modified content to the response stream again.

The problem: all inside the output stream is empty, I can not get the
content of the resources sent to the client.

I assume / know that Tapestry does some wrapping around the
HttpServletResponse and -Request and handles it in own services.

The question: can you please tell me, what is the correct way in Tapestry
to modify the content of e.g. static resources (like js files) and write
this modified content to the output stream?

Thanks for your help!

Best Regards
Eric


Re: Trigger Alert from javascript

2019-03-04 Thread D. R.

ok, very easy:

include "t5/core/alert" as 'alert' and call:

var alertObject = {
  message: 'hi from javascript',
  severity: 'ERROR', // SUCCESS, INFO, WARN, ERROR
};
alert(alertObject);

Any concerns about that?

Kind regards
David

Am 05.03.19 um 06:23 schrieb D. R.:

Hi,

we want to trigger an t5-Alert from javascript, how can we do that?

Kind regards
David



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



Trigger Alert from javascript

2019-03-04 Thread D. R.

Hi,

we want to trigger an t5-Alert from javascript, how can we do that?

Kind regards
David


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



Re: Add javascript to every request response

2018-12-24 Thread Nathan Quirynen

Thanks a lot for the very detailed answer!

Exactly what I needed.

Op 21/12/18 om 21:05 schreef Cezary Biernacki:

Yes, it possible. There are probably several ways to do that, one of them
is by contributing to MarkupRenderer and PartialMarkupRenderer. Start first
by putting your JavaScript in a JavaScript module, META-INF/modules
directory define a JavaScript file like this (of course customise it to
whatever you need):

META-INF/modules/mymodule.js

define([], function () {
 var exports = {};
 exports.greetings = function (name) {
 console.log("Hello " + name);
 };

 return exports;
 }
);


Then define a Tapestry service that invokes this JavaScript code using
Tapestry's JavaScriptSupport service:

GreetingsInserter.java (I skipped all usual imports and package definitions
for brevity here)

public class GreetingsInserter {
 private final JavaScriptSupport javaScriptSupport;

 public GreetingsInserter(final JavaScriptSupport javaScriptSupport) {
 this.javaScriptSupport = javaScriptSupport;
 }

 public void insertGreetings() {
 
javaScriptSupport.require("mymodule").invoke("greetings").with("World");
 }
}


now in Tapestry's module class (e.g. AppModule.jave) you need to bind this
service

public static void bind(@Nonnull final ServiceBinder binder) {
 // ... usually there are bindings for other services here too
binder.bind(GreetingsInserter.class);}


and add contributions, like this:

@Contribute(MarkupRenderer.class)
public static void
addExampleGreetingsMarkupRendererContribution(OrderedConfiguration
configuration, GreetingsInserter greetingsInserter) {
 configuration.add("greetings", (writer, renderer) -> {
 greetingsInserter.insertGreetings();
 renderer.renderMarkup(writer);
 }, "after:JavaScriptSupport");
}

@Contribute(PartialMarkupRenderer.class)
public static void
addExampleGreetingsContribution(OrderedConfiguration
configuration, GreetingsInserter greetingsInserter) {
 configuration.add("greetings", (writer, reply, renderer) -> {
 greetingsInserter.insertGreetings();
 renderer.renderMarkup(writer, reply);
 }, "after:JavaScriptSupport");
}


It should now work for both normal and AJAX calls. You can potentially
invoke different JavaScript codes depending on requests, though I would
recommend avoiding too complex logic as any error might totally disable
your application including even error pages. You can play with
initialisation priorities to control when this JavaScript code is invoked
during rendering, e.g.:

public void insertGreetings() {
 
javaScriptSupport.require("mymodule").invoke("greetings").priority(InitializationPriority.EARLY).with("World");
}


Best regards,
Cezary


On Fri, Dec 21, 2018 at 3:39 PM Nathan Quirynen 
wrote:


Hi,

Is it possible to add javascript or some javascript module call to every
(also xhr) requests response?

Nathan


-
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: Add javascript to every request response

2018-12-21 Thread Thiago H. de Paula Figueiredo
That's a nice solution, Cezary!

Another one is to create a mixin and apply it to all component pages by
implementing a ComponentClassTransformer and contributing it to the
ComponentClassTransformWorker and using
MutableComponentModel.addMixinClassName().

On Fri, Dec 21, 2018 at 6:25 PM Cezary Biernacki 
wrote:

> Yes, it possible. There are probably several ways to do that, one of them
> is by contributing to MarkupRenderer and PartialMarkupRenderer. Start first
> by putting your JavaScript in a JavaScript module, META-INF/modules
> directory define a JavaScript file like this (of course customise it to
> whatever you need):
>
> META-INF/modules/mymodule.js
>
> define([], function () {
> var exports = {};
> exports.greetings = function (name) {
> console.log("Hello " + name);
> };
>
> return exports;
> }
> );
>
>
> Then define a Tapestry service that invokes this JavaScript code using
> Tapestry's JavaScriptSupport service:
>
> GreetingsInserter.java (I skipped all usual imports and package definitions
> for brevity here)
>
> public class GreetingsInserter {
> private final JavaScriptSupport javaScriptSupport;
>
> public GreetingsInserter(final JavaScriptSupport javaScriptSupport) {
> this.javaScriptSupport = javaScriptSupport;
> }
>
> public void insertGreetings() {
>
> javaScriptSupport.require("mymodule").invoke("greetings").with("World");
> }
> }
>
>
> now in Tapestry's module class (e.g. AppModule.jave) you need to bind this
> service
>
> public static void bind(@Nonnull final ServiceBinder binder) {
> // ... usually there are bindings for other services here too
>binder.bind(GreetingsInserter.class);}
>
>
> and add contributions, like this:
>
> @Contribute(MarkupRenderer.class)
> public static void
>
> addExampleGreetingsMarkupRendererContribution(OrderedConfiguration
> configuration, GreetingsInserter greetingsInserter) {
> configuration.add("greetings", (writer, renderer) -> {
> greetingsInserter.insertGreetings();
> renderer.renderMarkup(writer);
> }, "after:JavaScriptSupport");
> }
>
> @Contribute(PartialMarkupRenderer.class)
> public static void
>
> addExampleGreetingsContribution(OrderedConfiguration
> configuration, GreetingsInserter greetingsInserter) {
> configuration.add("greetings", (writer, reply, renderer) -> {
> greetingsInserter.insertGreetings();
> renderer.renderMarkup(writer, reply);
> }, "after:JavaScriptSupport");
> }
>
>
> It should now work for both normal and AJAX calls. You can potentially
> invoke different JavaScript codes depending on requests, though I would
> recommend avoiding too complex logic as any error might totally disable
> your application including even error pages. You can play with
> initialisation priorities to control when this JavaScript code is invoked
> during rendering, e.g.:
>
> public void insertGreetings() {
>
> javaScriptSupport.require("mymodule").invoke("greetings").priority(InitializationPriority.EARLY).with("World");
> }
>
>
> Best regards,
> Cezary
>
>
> On Fri, Dec 21, 2018 at 3:39 PM Nathan Quirynen <
> nat...@pensionarchitects.be>
> wrote:
>
> > Hi,
> >
> > Is it possible to add javascript or some javascript module call to every
> > (also xhr) requests response?
> >
> > Nathan
> >
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> > For additional commands, e-mail: users-h...@tapestry.apache.org
> >
> >
>


-- 
Thiago


Re: Add javascript to every request response

2018-12-21 Thread Cezary Biernacki
Yes, it possible. There are probably several ways to do that, one of them
is by contributing to MarkupRenderer and PartialMarkupRenderer. Start first
by putting your JavaScript in a JavaScript module, META-INF/modules
directory define a JavaScript file like this (of course customise it to
whatever you need):

META-INF/modules/mymodule.js

define([], function () {
var exports = {};
exports.greetings = function (name) {
console.log("Hello " + name);
};

return exports;
}
);


Then define a Tapestry service that invokes this JavaScript code using
Tapestry's JavaScriptSupport service:

GreetingsInserter.java (I skipped all usual imports and package definitions
for brevity here)

public class GreetingsInserter {
private final JavaScriptSupport javaScriptSupport;

public GreetingsInserter(final JavaScriptSupport javaScriptSupport) {
this.javaScriptSupport = javaScriptSupport;
}

public void insertGreetings() {
javaScriptSupport.require("mymodule").invoke("greetings").with("World");
}
}


now in Tapestry's module class (e.g. AppModule.jave) you need to bind this
service

public static void bind(@Nonnull final ServiceBinder binder) {
// ... usually there are bindings for other services here too
   binder.bind(GreetingsInserter.class);}


and add contributions, like this:

@Contribute(MarkupRenderer.class)
public static void
addExampleGreetingsMarkupRendererContribution(OrderedConfiguration
configuration, GreetingsInserter greetingsInserter) {
configuration.add("greetings", (writer, renderer) -> {
greetingsInserter.insertGreetings();
renderer.renderMarkup(writer);
}, "after:JavaScriptSupport");
}

@Contribute(PartialMarkupRenderer.class)
public static void
addExampleGreetingsContribution(OrderedConfiguration
configuration, GreetingsInserter greetingsInserter) {
configuration.add("greetings", (writer, reply, renderer) -> {
greetingsInserter.insertGreetings();
renderer.renderMarkup(writer, reply);
}, "after:JavaScriptSupport");
}


It should now work for both normal and AJAX calls. You can potentially
invoke different JavaScript codes depending on requests, though I would
recommend avoiding too complex logic as any error might totally disable
your application including even error pages. You can play with
initialisation priorities to control when this JavaScript code is invoked
during rendering, e.g.:

public void insertGreetings() {

javaScriptSupport.require("mymodule").invoke("greetings").priority(InitializationPriority.EARLY).with("World");
}


Best regards,
Cezary


On Fri, Dec 21, 2018 at 3:39 PM Nathan Quirynen 
wrote:

> Hi,
>
> Is it possible to add javascript or some javascript module call to every
> (also xhr) requests response?
>
> Nathan
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Add javascript to every request response

2018-12-21 Thread Nathan Quirynen

Hi,

Is it possible to add javascript or some javascript module call to every 
(also xhr) requests response?


Nathan


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



Re: JavaScript not invoked on zone refresh

2018-10-01 Thread Christopher Dodunski
Thanks Chris & JumpStart, with your help I was able to get this CSS
animation working, using JavaScriptSupport in combination with RequireJS.

Below is the code, for anyone else wishing to do the same.

**The CSS**

.open-section{
transition:0s;
transform: rotate(90deg);
}
.close-section{
transition:0s;
transform: rotate(-90deg);
}
.accordion.active .open-section {
transition:1.0s;
transform: rotate(0deg);
}
.accordion.active .close-section {
transition:1.0s;
transform: rotate(0deg);
}

The animation occurs simply by adding one of the latter two classes to its
former counterpart.  The first two display the button 90 degrees offset
(hence the animation).

**The Component's Java Code**

public void afterRender(){

//Invoke client-side javascript to rotate the 'accordion' helm for
this component/zone
javaScriptSupport.require("activate-helm").with("userAccordion");
}

**The RequireJS Script**

define(["jquery"], function($){

return function(accordionId){
var element = document.getElementById(accordionId);
element.classList.add("active");
}

})

The page contains multiple zones, and the above animates the button within
a zone that gets refreshed.

The only glitch is that occasionally, especially with Firefox browser, the
button jumps rather than rotates to it's final position.  I suspect the
browser may be prematurely acting on the 'active' version of the CSS
class, before displaying the button in its initial 90 degree offset
position.  I'm not quite sure yet how to remedy this.  I think having the
RequireJS script wait a while would be a bit of a hack.

Regards,

Chris.


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



Re: Using JavaScript during Ajax request

2018-09-28 Thread Chris Poulsen
Hi

I'd say that you were off track. Tapestry already provides you with the
means to do what you need (the mentioned ajaxResponseRenderer callback for
ajax requests), so attempting to manipulate the environment to achieve what
is already supported, sounds like the recipe for creating something that
may break on a tapestry upgrade etc.

I can't say what the "intended" purpose of the t:trigger is, but as far as
I can tell from our codebase we mostly use it to plug in behavior
(essentially manipulating the markup writer) at specific points during
template rendering (and we have almost no usages). Almost all the usages we
have seems to be related to making sure that informal parameters end up on
the correct html element.

HTH.

-- 
Chris


On Thu, Sep 27, 2018 at 3:47 PM Davide Vecchi  wrote:

> Thanks guys, that was it. Worked right away.
>
> Now my problem is solved, but I'm wondering how off-track I was when I
> thought that the Trigger component was the way to go about this. Is Trigger
> intended for different situations, or is it just another possible
> appropriate way of solving this problem, or would it have been possible to
> solve this using Trigger but it wouldn't have been the right way ?
>
> In any case, as usual I solved my problem by asking here, thanks again.
>
>
> -Original Message-
> From: JumpStart 
> Sent: Thursday, September 27, 2018 14:21
> To: Tapestry users 
> Subject: Re: Using JavaScript during Ajax request
>
> An example:
>
>
> http://jumpstart.doublenegative.com.au/jumpstart/examples/javascript/modal/1
> <
> http://jumpstart.doublenegative.com.au/jumpstart/examples/javascript/modal/1
> >
>
>
> > On 27 Sep 2018, at 7:06 pm, Nathan Quirynen 
> wrote:
> >
> > When your request is an ajax call, you can use the following construct
> to use the JavaScriptSupport service:
> >
> > ajaxResponseRenderer.addCallback(new JavaScriptCallback() {
> > @Override
> > public void run(JavaScriptSupport javascriptSupport) {
> >
> > // Your code here
> >
> > }
> > }
> >
> >
> > Op 27/09/2018 om 10:59 schreef Davide Vecchi:
> >> Hello everybody,
> >>
> >> I am having exactly the same problem described in the thread linked
> >> below, that is the exception
> >>
> >> "No object of type
> org.apache.tapestry5.services.javascript.JavaScriptSupport is available
> from the Environment"
> >>
> >> that occurs only if the event handler is handling an Ajax request:
> >>
> >> http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/No
> >> -object-of-type-org-apache-tapestry5-services-javascript-JavaScriptSu
> >> pport-is-available-from-the-E-tp5551633p5551729.html
> >>
> >> My stacktrace is at the bottom of this email.
> >>
> >> The event being handled in my case is the click on an EventLink that
> has its t:zone attribute set to the name of a zone.
> >>
> >> In that thread jochenfrey explains that he solved the problem using the
> Trigger component to "get Tapestry Initializer Calls into the Response",
> which I think is what I need as well.
> >>
> >> However, I don't know where in the template the  tag must be
> placed. I'm also not sure what the event handler of the trigger should do
> in order to provide JavaScript to the EventLink handler. So those are my
> two questions.
> >>
> >> My understanding is that the Trigger event handler should push the
> JavaScriptSupport instance on the stack, so I do:
> >>
> >> environment.push(JavaScriptSupport.class, javaScriptSupport);
> >>
> >> but I'm not sure that's what is needed, and anyway it doesn't work for
> me, it get that exception.
> >>
> >> I have put the  tag immediately after the opening tag of the
> zone the EventLink is bound to:
> >>
> >>
> >> =
> >> ===
> >>
> >> 
> >>
> >> 
> >>
> >> ..
> >> 
> >>
> >> 
> >>
> >> 
> >>
> >>   ..
> >>
> >>   
> >>
> >> ..
> >>  >
> >>   Click me.
> >> 
> >>
> >> 
> >>
> >> 
> >>
> >>   
> >>
> >>
>

RE: Using JavaScript during Ajax request

2018-09-27 Thread Davide Vecchi
Thanks guys, that was it. Worked right away.

Now my problem is solved, but I'm wondering how off-track I was when I thought 
that the Trigger component was the way to go about this. Is Trigger intended 
for different situations, or is it just another possible appropriate way of 
solving this problem, or would it have been possible to solve this using 
Trigger but it wouldn't have been the right way ?

In any case, as usual I solved my problem by asking here, thanks again.


-Original Message-
From: JumpStart  
Sent: Thursday, September 27, 2018 14:21
To: Tapestry users 
Subject: Re: Using JavaScript during Ajax request

An example:


http://jumpstart.doublenegative.com.au/jumpstart/examples/javascript/modal/1 
<http://jumpstart.doublenegative.com.au/jumpstart/examples/javascript/modal/1>


> On 27 Sep 2018, at 7:06 pm, Nathan Quirynen  
> wrote:
> 
> When your request is an ajax call, you can use the following construct to use 
> the JavaScriptSupport service:
> 
> ajaxResponseRenderer.addCallback(new JavaScriptCallback() {
> @Override
> public void run(JavaScriptSupport javascriptSupport) {
> 
> // Your code here
> 
> }
> }
> 
> 
> Op 27/09/2018 om 10:59 schreef Davide Vecchi:
>> Hello everybody,
>> 
>> I am having exactly the same problem described in the thread linked 
>> below, that is the exception
>> 
>> "No object of type 
>> org.apache.tapestry5.services.javascript.JavaScriptSupport is available from 
>> the Environment"
>> 
>> that occurs only if the event handler is handling an Ajax request:
>> 
>> http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/No
>> -object-of-type-org-apache-tapestry5-services-javascript-JavaScriptSu
>> pport-is-available-from-the-E-tp5551633p5551729.html
>> 
>> My stacktrace is at the bottom of this email.
>> 
>> The event being handled in my case is the click on an EventLink that has its 
>> t:zone attribute set to the name of a zone.
>> 
>> In that thread jochenfrey explains that he solved the problem using the 
>> Trigger component to "get Tapestry Initializer Calls into the Response", 
>> which I think is what I need as well.
>> 
>> However, I don't know where in the template the  tag must be 
>> placed. I'm also not sure what the event handler of the trigger should do in 
>> order to provide JavaScript to the EventLink handler. So those are my two 
>> questions.
>> 
>> My understanding is that the Trigger event handler should push the 
>> JavaScriptSupport instance on the stack, so I do:
>> 
>> environment.push(JavaScriptSupport.class, javaScriptSupport);
>> 
>> but I'm not sure that's what is needed, and anyway it doesn't work for me, 
>> it get that exception.
>> 
>> I have put the  tag immediately after the opening tag of the zone 
>> the EventLink is bound to:
>> 
>> 
>> =
>> ===
>> 
>> 
>> 
>> 
>> 
>> ..
>> 
>> 
>> 
>> 
>> 
>> 
>>   ..
>> 
>>   
>> 
>> ..
>> 
>>   Click me.
>> 
>> 
>> 
>> 
>> 
>> 
>>   
>> 
>> 
>> -
>> -
>> 
>>@Environmental
>>private JavaScriptSupport javaScriptSupport;
>> 
>>@Inject
>>private Environment environment;
>> 
>>void onJavaScriptNeeded()
>>{
>>   this.environment.push(JavaScriptSupport.class, 
>> this.javaScriptSupport);
>>}
>> 
>> 
>> =
>> ===
>> 
>> I don't know if the following matters, however:
>> 
>> 
>>   *   The zone the EventLink is bound to is defined only in the template (in 
>> the Java code I never need to return that zone from any method or do 
>> anything with it so I did not create any Zone field for that zone).
>> 
>> 
>>   *   In the template, the EventLink is itself inside a zone, which is 
>> nested inside another zone.
>> 
>> 
>> 
>>   *   The "javaScriptNee

Re: Using JavaScript during Ajax request

2018-09-27 Thread JumpStart
An example:


http://jumpstart.doublenegative.com.au/jumpstart/examples/javascript/modal/1 
<http://jumpstart.doublenegative.com.au/jumpstart/examples/javascript/modal/1>


> On 27 Sep 2018, at 7:06 pm, Nathan Quirynen  
> wrote:
> 
> When your request is an ajax call, you can use the following construct to use 
> the JavaScriptSupport service:
> 
> ajaxResponseRenderer.addCallback(new JavaScriptCallback() {
> @Override
> public void run(JavaScriptSupport javascriptSupport) {
> 
> // Your code here
> 
> }
> }
> 
> 
> Op 27/09/2018 om 10:59 schreef Davide Vecchi:
>> Hello everybody,
>> 
>> I am having exactly the same problem described in the thread linked below, 
>> that is the exception
>> 
>> "No object of type 
>> org.apache.tapestry5.services.javascript.JavaScriptSupport is available from 
>> the Environment"
>> 
>> that occurs only if the event handler is handling an Ajax request:
>> 
>> http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/No-object-of-type-org-apache-tapestry5-services-javascript-JavaScriptSupport-is-available-from-the-E-tp5551633p5551729.html
>> 
>> My stacktrace is at the bottom of this email.
>> 
>> The event being handled in my case is the click on an EventLink that has its 
>> t:zone attribute set to the name of a zone.
>> 
>> In that thread jochenfrey explains that he solved the problem using the 
>> Trigger component to "get Tapestry Initializer Calls into the Response", 
>> which I think is what I need as well.
>> 
>> However, I don't know where in the template the  tag must be 
>> placed. I'm also not sure what the event handler of the trigger should do in 
>> order to provide JavaScript to the EventLink handler. So those are my two 
>> questions.
>> 
>> My understanding is that the Trigger event handler should push the 
>> JavaScriptSupport instance on the stack, so I do:
>> 
>> environment.push(JavaScriptSupport.class, javaScriptSupport);
>> 
>> but I'm not sure that's what is needed, and anyway it doesn't work for me, 
>> it get that exception.
>> 
>> I have put the  tag immediately after the opening tag of the zone 
>> the EventLink is bound to:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> ..
>> 
>> 
>> 
>> 
>> 
>> 
>>   ..
>> 
>>   
>> 
>> ..
>> 
>>   Click me.
>> 
>> 
>> 
>> 
>> 
>> 
>>   
>> 
>> 
>> --
>> 
>>@Environmental
>>private JavaScriptSupport javaScriptSupport;
>> 
>>@Inject
>>private Environment environment;
>> 
>>void onJavaScriptNeeded()
>>{
>>   this.environment.push(JavaScriptSupport.class, 
>> this.javaScriptSupport);
>>}
>> 
>> 
>> 
>> 
>> I don't know if the following matters, however:
>> 
>> 
>>   *   The zone the EventLink is bound to is defined only in the template (in 
>> the Java code I never need to return that zone from any method or do 
>> anything with it so I did not create any Zone field for that zone).
>> 
>> 
>>   *   In the template, the EventLink is itself inside a zone, which is 
>> nested inside another zone.
>> 
>> 
>> 
>>   *   The "javaScriptNeeded"  event occurs when the page is loaded. It does 
>> not occur when I click the link.
>> 
>> 
>> Thanks for any possible hint.
>> 
>> 
>> org.apache.tapestry5.ioc.util.UnknownValueException: No object of type 
>> org.apache.tapestry5.services.javascript.JavaScriptSupport is available from 
>> the Environment.
>> at 
>> org.apache.tapestry5.internal.services.EnvironmentImpl.peekRequired(EnvironmentImpl.java:96)
>> at $Environment_4a157190551.peekRequired(Unknown Source)
>> at $Environment_4a157190347.peekRequired(Unknown Source)
>

Re: Using JavaScript during Ajax request

2018-09-27 Thread Nathan Quirynen
When your request is an ajax call, you can use the following construct 
to use the JavaScriptSupport service:


ajaxResponseRenderer.addCallback(new JavaScriptCallback() {
            @Override
            public void run(JavaScriptSupport javascriptSupport) {

                // Your code here

            }
}


Op 27/09/2018 om 10:59 schreef Davide Vecchi:

Hello everybody,

I am having exactly the same problem described in the thread linked below, that 
is the exception

"No object of type org.apache.tapestry5.services.javascript.JavaScriptSupport is 
available from the Environment"

that occurs only if the event handler is handling an Ajax request:

http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/No-object-of-type-org-apache-tapestry5-services-javascript-JavaScriptSupport-is-available-from-the-E-tp5551633p5551729.html

My stacktrace is at the bottom of this email.

The event being handled in my case is the click on an EventLink that has its 
t:zone attribute set to the name of a zone.

In that thread jochenfrey explains that he solved the problem using the Trigger component 
to "get Tapestry Initializer Calls into the Response", which I think is what I 
need as well.

However, I don't know where in the template the  tag must be placed. 
I'm also not sure what the event handler of the trigger should do in order to provide 
JavaScript to the EventLink handler. So those are my two questions.

My understanding is that the Trigger event handler should push the 
JavaScriptSupport instance on the stack, so I do:

environment.push(JavaScriptSupport.class, javaScriptSupport);

but I'm not sure that's what is needed, and anyway it doesn't work for me, it 
get that exception.

I have put the  tag immediately after the opening tag of the zone the 
EventLink is bound to:

 






..


 

 

   ..

   

 ..
 
   Click me.


 



   

 
--

@Environmental
private JavaScriptSupport javaScriptSupport;

@Inject
private Environment environment;

void onJavaScriptNeeded()
{
   this.environment.push(JavaScriptSupport.class, 
this.javaScriptSupport);
}

 


I don't know if the following matters, however:


   *   The zone the EventLink is bound to is defined only in the template (in 
the Java code I never need to return that zone from any method or do anything 
with it so I did not create any Zone field for that zone).


   *   In the template, the EventLink is itself inside a zone, which is nested 
inside another zone.



   *   The "javaScriptNeeded"  event occurs when the page is loaded. It does 
not occur when I click the link.


Thanks for any possible hint.


org.apache.tapestry5.ioc.util.UnknownValueException: No object of type 
org.apache.tapestry5.services.javascript.JavaScriptSupport is available from 
the Environment.
 at 
org.apache.tapestry5.internal.services.EnvironmentImpl.peekRequired(EnvironmentImpl.java:96)
 at $Environment_4a157190551.peekRequired(Unknown Source)
 at $Environment_4a157190347.peekRequired(Unknown Source)
 at 
org.apache.tapestry5.internal.transform.EnvironmentalWorker$EnvironmentalConduit.get(EnvironmentalWorker.java:59)
 at 
mypackage.tapestry.pages.main.MyPage.conduit_get_javaScriptSupport(MyAccount.java)
 at 
mypackage.tapestry.pages.main.MyPage.onChangeCredentialsBtn(MyAccount.java:814)
 at 
mypackage.tapestry.pages.main.MyPage.dispatchComponentEvent(MyAccount.java)
 at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.dispatchEvent(ComponentPageElementImpl.java:917)
 at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.processEventTriggering(ComponentPageElementImpl.java:1102)
 at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access$3100(ComponentPageElementImpl.java:57)
 at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5.invoke(ComponentPageElementImpl.java:1047)
 at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5.invoke(ComponentPageElementImpl.java:1044)
 at 
org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:82)
 at 
org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperati

Using JavaScript during Ajax request

2018-09-27 Thread Davide Vecchi
Hello everybody,

I am having exactly the same problem described in the thread linked below, that 
is the exception

"No object of type org.apache.tapestry5.services.javascript.JavaScriptSupport 
is available from the Environment"

that occurs only if the event handler is handling an Ajax request:

http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/No-object-of-type-org-apache-tapestry5-services-javascript-JavaScriptSupport-is-available-from-the-E-tp5551633p5551729.html

My stacktrace is at the bottom of this email.

The event being handled in my case is the click on an EventLink that has its 
t:zone attribute set to the name of a zone.

In that thread jochenfrey explains that he solved the problem using the Trigger 
component to "get Tapestry Initializer Calls into the Response", which I think 
is what I need as well.

However, I don't know where in the template the  tag must be placed. 
I'm also not sure what the event handler of the trigger should do in order to 
provide JavaScript to the EventLink handler. So those are my two questions.

My understanding is that the Trigger event handler should push the 
JavaScriptSupport instance on the stack, so I do:

environment.push(JavaScriptSupport.class, javaScriptSupport);

but I'm not sure that's what is needed, and anyway it doesn't work for me, it 
get that exception.

I have put the  tag immediately after the opening tag of the zone the 
EventLink is bound to:








..






  ..

  

..

  Click me.






  


--

   @Environmental
   private JavaScriptSupport javaScriptSupport;

   @Inject
   private Environment environment;

   void onJavaScriptNeeded()
   {
  this.environment.push(JavaScriptSupport.class, 
this.javaScriptSupport);
   }




I don't know if the following matters, however:


  *   The zone the EventLink is bound to is defined only in the template (in 
the Java code I never need to return that zone from any method or do anything 
with it so I did not create any Zone field for that zone).


  *   In the template, the EventLink is itself inside a zone, which is nested 
inside another zone.



  *   The "javaScriptNeeded"  event occurs when the page is loaded. It does not 
occur when I click the link.


Thanks for any possible hint.


org.apache.tapestry5.ioc.util.UnknownValueException: No object of type 
org.apache.tapestry5.services.javascript.JavaScriptSupport is available from 
the Environment.
at 
org.apache.tapestry5.internal.services.EnvironmentImpl.peekRequired(EnvironmentImpl.java:96)
at $Environment_4a157190551.peekRequired(Unknown Source)
at $Environment_4a157190347.peekRequired(Unknown Source)
at 
org.apache.tapestry5.internal.transform.EnvironmentalWorker$EnvironmentalConduit.get(EnvironmentalWorker.java:59)
at 
mypackage.tapestry.pages.main.MyPage.conduit_get_javaScriptSupport(MyAccount.java)
at 
mypackage.tapestry.pages.main.MyPage.onChangeCredentialsBtn(MyAccount.java:814)
at 
mypackage.tapestry.pages.main.MyPage.dispatchComponentEvent(MyAccount.java)
at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.dispatchEvent(ComponentPageElementImpl.java:917)
at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.processEventTriggering(ComponentPageElementImpl.java:1102)
at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access$3100(ComponentPageElementImpl.java:57)
at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5.invoke(ComponentPageElementImpl.java:1047)
at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5.invoke(ComponentPageElementImpl.java:1044)
at 
org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:82)
at 
org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:72)
at 
org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1260)
at 
org.apache.tapestry5.internal.structure.ComponentPageElementResourcesImpl.invoke(ComponentPageElementResourcesImpl.java:154)
at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageEle

Re: JavaScript not invoked on zone refresh

2018-09-26 Thread JumpStart
Examples can be found in JumpStart, starting here:


http://jumpstart.doublenegative.com.au/jumpstart/examples/javascript/javascript

> On 26 Sep 2018, at 3:19 pm, Chris Poulsen  wrote:
> 
> Reacting to the zone events sounds like the best option IMO. Controlling
> this from the server side seems needlessly complex and fragile in this case.
> 
> Not really related to your issue, but you can call exported module methods
> in 5.4 like this:
> 
> JSONObject specification = new JSONObject( "diagramClientId",
> diagram.getClientId(), "modelJson", modelJson );
> 
> jsSupport.require( "pages/contentspace/content-space-index" ).invoke(
> "init" ).with( specification );
> 
> HTH.
> 
> -- 
> Chris
> 
> On Wed, Sep 26, 2018 at 1:10 AM Christopher Dodunski <
> chrisfromtapes...@christopher.net.nz> wrote:
> 
>> After exploring a little further, I discovered the below thread on
>> invoking javascript from within Tapestry.
>> 
>> 
>> https://stackoverflow.com/questions/27988473/pass-parameter-from-java-to-js-in-tapestry
>> 
>> Joost writes:
>> 
>> You will need to use the JavaScriptSupport service.
>> 
>> Your java file:
>> 
>> @Import(library = "RoomManagement.js")
>> public final class RoomManagement{
>> 
>>  @Inject
>>  private JavaScriptSupport javascriptSupport;
>> 
>>  @Property
>>  private long contactId;
>> 
>>  @AfterRender
>>  private void setup() {
>>JSONObject jsonObject = new JSONObject();
>>jsonObject.put("contactId", contactId);
>>javascriptSupport.addInitializerCall("RoomManagement",jsonObject);
>>  }
>> }
>> 
>> Your RoomManagement.js
>> 
>> Tapestry.Initializer.RoomManagement = function (parameters) {
>>//do whatever you need here
>>alert('Your contactId: ' + parameters.contactId);
>> };
>> 
>> This looks promising, but I later read that Tapestry's handling of
>> javascript has been completely rewritten in Tapestry 5.4, with the above
>> being deprecated.  And I've not found any example code of doing tnings the
>> new way.  Any pointers would be much appreciated.
>> 
>> My page contains 10 expand/collapse buttons, and I only wish to animate
>> the one connected to the zone being updated.  So am thinking of giving
>> each button a unique ID, and passing that ID to the javascript so just the
>> one button animates.
>> 
>> My needs are pretty straight forward, and reportedly Tapestry's javascript
>> handling was completely rewritten in 5.4 to simplify things.  Look forward
>> to seeing how things now get done.  :-)
>> 
>> Appreciate any help.
>> 
>> Regards,
>> 
>> Chris.
>> 
>> 
>> -
>> 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: JavaScript not invoked on zone refresh

2018-09-26 Thread Chris Poulsen
Reacting to the zone events sounds like the best option IMO. Controlling
this from the server side seems needlessly complex and fragile in this case.

Not really related to your issue, but you can call exported module methods
in 5.4 like this:

JSONObject specification = new JSONObject( "diagramClientId",
diagram.getClientId(), "modelJson", modelJson );

jsSupport.require( "pages/contentspace/content-space-index" ).invoke(
"init" ).with( specification );

HTH.

-- 
Chris

On Wed, Sep 26, 2018 at 1:10 AM Christopher Dodunski <
chrisfromtapes...@christopher.net.nz> wrote:

> After exploring a little further, I discovered the below thread on
> invoking javascript from within Tapestry.
>
>
> https://stackoverflow.com/questions/27988473/pass-parameter-from-java-to-js-in-tapestry
>
> Joost writes:
>
> You will need to use the JavaScriptSupport service.
>
> Your java file:
>
> @Import(library = "RoomManagement.js")
> public final class RoomManagement{
>
>   @Inject
>   private JavaScriptSupport javascriptSupport;
>
>   @Property
>   private long contactId;
>
>   @AfterRender
>   private void setup() {
> JSONObject jsonObject = new JSONObject();
> jsonObject.put("contactId", contactId);
> javascriptSupport.addInitializerCall("RoomManagement",jsonObject);
>   }
> }
>
> Your RoomManagement.js
>
> Tapestry.Initializer.RoomManagement = function (parameters) {
>     //do whatever you need here
> alert('Your contactId: ' + parameters.contactId);
> };
>
> This looks promising, but I later read that Tapestry's handling of
> javascript has been completely rewritten in Tapestry 5.4, with the above
> being deprecated.  And I've not found any example code of doing tnings the
> new way.  Any pointers would be much appreciated.
>
> My page contains 10 expand/collapse buttons, and I only wish to animate
> the one connected to the zone being updated.  So am thinking of giving
> each button a unique ID, and passing that ID to the javascript so just the
> one button animates.
>
> My needs are pretty straight forward, and reportedly Tapestry's javascript
> handling was completely rewritten in 5.4 to simplify things.  Look forward
> to seeing how things now get done.  :-)
>
> Appreciate any help.
>
> Regards,
>
> Chris.
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: JavaScript not invoked on zone refresh

2018-09-25 Thread Christopher Dodunski
After exploring a little further, I discovered the below thread on
invoking javascript from within Tapestry.

https://stackoverflow.com/questions/27988473/pass-parameter-from-java-to-js-in-tapestry

Joost writes:

You will need to use the JavaScriptSupport service.

Your java file:

@Import(library = "RoomManagement.js")
public final class RoomManagement{

  @Inject
  private JavaScriptSupport javascriptSupport;

  @Property
  private long contactId;

  @AfterRender
  private void setup() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("contactId", contactId);
javascriptSupport.addInitializerCall("RoomManagement",jsonObject);
  }
}

Your RoomManagement.js

Tapestry.Initializer.RoomManagement = function (parameters) {
//do whatever you need here
alert('Your contactId: ' + parameters.contactId);
};

This looks promising, but I later read that Tapestry's handling of
javascript has been completely rewritten in Tapestry 5.4, with the above
being deprecated.  And I've not found any example code of doing tnings the
new way.  Any pointers would be much appreciated.

My page contains 10 expand/collapse buttons, and I only wish to animate
the one connected to the zone being updated.  So am thinking of giving
each button a unique ID, and passing that ID to the javascript so just the
one button animates.

My needs are pretty straight forward, and reportedly Tapestry's javascript
handling was completely rewritten in 5.4 to simplify things.  Look forward
to seeing how things now get done.  :-)

Appreciate any help.

Regards,

Chris.


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



Re: JavaScript not invoked on zone refresh

2018-09-25 Thread Christopher Dodunski
Thanks Chung and Chris.

I doubt using .click() will work, as the button being clicked on is
immediately replaced, and it is this new button that must rotate.  The
buttons are for expanding and collpasing sections of a webpage.  Once a
user clicks on an expand button, it is immediately replaced with a
collapse button.  And vice versa.  Below is the TML:


















Chris, invoking my javascript within the page's Java code sounds
interesting.  I've not done this before, but will look into it.  Do you
have any sample code for this approach?

Thanks,

Chris.


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



Re: JavaScript not invoked on zone refresh

2018-09-24 Thread Chris Poulsen
Hi

Zone updates are updates of parts of the page, so the ready function is not
triggered for those. Consider also performing your initialization on zone
updates. See:
http://tapestry.apache.org/current/coffeescript/events.html#section-20 for
the zone related events.

-- 
Chris

On Tue, Sep 25, 2018 at 7:22 AM Christopher Dodunski <
chrisfromtapes...@christopher.net.nz> wrote:

> Hi all,
>
> I suspect there's a simple solution to this small, but annoying problem.
>
> My Tapestry page uses a simple javascript to rotate an image 90 degrees
> the moment the image is rendered on screen.  It does this by adding a CSS
> class to the button element that contains the image.
>
>
> **The JavaScript**
>
> $(document).ready(function(){
> $('.accordion').addClass('active');
> });
>
>
> **The CSS Classes**
>
> .open-section{
> transform: rotate(0deg);
> transition:1s;
> }
> .close-section{
> transform: rotate(0deg);
> transition:1s;
> }
> .accordion.active .open-section {
> transform: rotate(-90deg);
> transition:1s;
> }
> .accordion.active .close-section {
> transform: rotate(90deg);
> transition:1s;
> }
>
>
> The above works perfectly well when the page first loads, and if I
> manually refresh the page.  But when the button/image appears within a
> zone that is refreshed, the javascript evidently doesn't get invoked, as
> the button image doesn't rotate.
>
> How would one normally resolve this little problem?
>
> Regards,
>
> Chris.
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: JavaScript not invoked on zone refresh

2018-09-24 Thread Chung Duy
Your javascript register when document is ready , it means just affect when
page load or refresh page. If you want handle it via button, please
register onclick event for this button and implement new small function
with call the same snippet. Assume you're using jquery, so here is my
thoughts:

$("button-id").click(function() {
$('.accordion').addClass('active');
})

On Tue, Sep 25, 2018 at 12:22 PM Christopher Dodunski <
chrisfromtapes...@christopher.net.nz> wrote:

> Hi all,
>
> I suspect there's a simple solution to this small, but annoying problem.
>
> My Tapestry page uses a simple javascript to rotate an image 90 degrees
> the moment the image is rendered on screen.  It does this by adding a CSS
> class to the button element that contains the image.
>
>
> **The JavaScript**
>
> $(document).ready(function(){
> $('.accordion').addClass('active');
> });
>
>
> **The CSS Classes**
>
> .open-section{
> transform: rotate(0deg);
> transition:1s;
> }
> .close-section{
> transform: rotate(0deg);
> transition:1s;
> }
> .accordion.active .open-section {
> transform: rotate(-90deg);
> transition:1s;
> }
> .accordion.active .close-section {
> transform: rotate(90deg);
> transition:1s;
> }
>
>
> The above works perfectly well when the page first loads, and if I
> manually refresh the page.  But when the button/image appears within a
> zone that is refreshed, the javascript evidently doesn't get invoked, as
> the button image doesn't rotate.
>
> How would one normally resolve this little problem?
>
> Regards,
>
> Chris.
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

-- 
Chung Khánh Duy
Director of Technology
Formos


JavaScript not invoked on zone refresh

2018-09-24 Thread Christopher Dodunski
Hi all,

I suspect there's a simple solution to this small, but annoying problem.

My Tapestry page uses a simple javascript to rotate an image 90 degrees
the moment the image is rendered on screen.  It does this by adding a CSS
class to the button element that contains the image.


**The JavaScript**

$(document).ready(function(){
$('.accordion').addClass('active');
});


**The CSS Classes**

.open-section{
transform: rotate(0deg);
transition:1s;
}
.close-section{
transform: rotate(0deg);
transition:1s;
}
.accordion.active .open-section {
transform: rotate(-90deg);
transition:1s;
}
.accordion.active .close-section {
transform: rotate(90deg);
transition:1s;
}


The above works perfectly well when the page first loads, and if I
manually refresh the page.  But when the button/image appears within a
zone that is refreshed, the javascript evidently doesn't get invoked, as
the button image doesn't rotate.

How would one normally resolve this little problem?

Regards,

Chris.


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



Re: How to pass a variable from Javascript code to Java

2018-08-30 Thread Cezary Biernacki
While cookies can be used the way you describe, I would like to warn that
they have several drawbacks. They are added to every requests from the
browser to the server, until they expire or some code explicitly deletes
them. It means that the size of unrelated requests might grow. Also it
complicates handling situations when user opens a page in several
tabs/windows, and the code would try to pass back different values (e.g.
based on user interactions with the page). There are also limits on the
size and number of cookies. Of course in some situations, cookies are the
best option (e.g. tracking some per-user state), but more often they are
not.

Cezary




On Thu, Aug 30, 2018 at 12:23 AM heph estos  wrote:

> And how about storing the value to a session or a cookie from javascript
> and reading from java server through an implemantation of observer
> parttern? It would work in any case, in any framework.
>
> Στις Τετ, 29 Αυγ 2018, 2:39 μ.μ. ο χρήστης marwa hussein <
> marwa.huss...@gmail.com> έγραψε:
>
> > Hi,
> > Thank you all for guiding me to the solution especially "Numa" .. and
> this
> > is how I solved it:
> > for the .tml
> > 
> >
> > and in the JS JQuery file, I passed the variable in a JSON object -->
> data:
> > {myData:dataToSend}
> > $('#myId').click(function() {
> > var dataToSend=  $('#myId').data('mydata');
> > ajax('answer', {
> > element: $('#myId'),
> > data:{ myData:dataToSend},
> > success: function(response) {
> > }
> > });
> > });
> >
> > and in java file, I used @RequestParameter("myData") to get the value
> from
> > the JSON object:
> >  @OnEvent("answer")
> >  @PublishEvent
> > public void answer(@RequestParameter("myData") String varName)
> > {
> > System.out.println("Variable name is :"+  varName  );
> > }
> >
> > Regards,
> > Marwa
> >
> >
> > On Tue, Aug 28, 2018 at 3:20 PM Numa Schmeder  wrote:
> >
> > > Hello Marwa,
> > >
> > > The answer provided by Thiago is much simpler.
> > > Just put your data in a data attribute of a tag and then use the
> tutorial
> > > ajax and zones to send this data to a server side event handler.
> > > If you want to do it automatically without triggering a javascript
> event,
> > > just put you script in an on document ready event, to make sure your
> > > javascript code is called once the page is rendered and loaded by the
> > > browser.
> > >
> > >
> > > ===> in html page
> > >
> > > 
> > >
> > > ===> javascript at the end of html page
> > >
> > > $(function() {
> > > var dataToSend = $(‘#myId’).data(‘mydata’);
> > > ajax(‘pageData', {
> > > data: dataToSend, // This doesn't need to be
> the
> > > same element as the one two lines above
> > > // Callback called when the request is finished.
> > > // response.json is the object returned by the event
> handler
> > > method
> > > success: function(response) {
> > > alert('sent to server');
> > > }
> > > });
> > > });
> > >
> > >
> > > => in java page
> > >
> > > JSONObject onPageData()
> > > {
> > >     return new JSONObject("origin", "componentAction");
> > > }
> > >
> > >
> > > You can use jquery or something else.
> > >
> > > Best
> > > Numa
> > >
> > >
> > >
> > >   <http://www.dfacto.ch/>   Numa Schmederwww.dfacto.ch  <
> > > http://www.dfacto.ch/>
> > > n...@dfacto.ch <mailto:n...@dfacto.ch>   |   M +41 79 538 30 01
> > >
> > > DIGITAL STRATEGY   |   DESIGN   |   DEVELOPMENT
> > >
> > >
> > >
> > >
> > > > Le 28 août 2018 à 12:22, marwa hussein  a
> > > écrit :
> > > >
> > > > Hello,
> > > >
> > > > Thanks all for your suggestions. I followed the example shown in
> > > > https://tapestry.apache.org/ajax-and-zones.html in "Invoking
> > server-side
> > > > event handler methods from JavaScript"   but here the event is in the
> > > java
> > > > code "server-side" and is invoked from the Javascript code
> "onClick()"
> > ,
> > > > but what I want is the opposite direction, sending a "string
> variable"
> > > from
> > > > a tag appended in  the clientside javascript code to the java code
> "in
> > > the
> > > > serverside".
> > > > For now, I will test to use hidden input (although I didn't want to
> > use a
> > > > form submit) and I will see if I can make it or not ...
> > > >
> > > > Thank you all for your help and valuable suggestions, and of course,
> if
> > > > anyone face the same problem before and could give me hints to how to
> > do
> > > it
> > > > please tell me.
> > > > Regards,
> > > > Marwa
> > >
> > >
> >
> > --
> >
> >
> >
> > *Marwa Hussein M. TA @ Information Systems Department Faculty of
> Computers
> > & Information Assuit University*
> > 
> >
>


Re: How to pass a variable from Javascript code to Java

2018-08-29 Thread heph estos
And how about storing the value to a session or a cookie from javascript
and reading from java server through an implemantation of observer
parttern? It would work in any case, in any framework.

Στις Τετ, 29 Αυγ 2018, 2:39 μ.μ. ο χρήστης marwa hussein <
marwa.huss...@gmail.com> έγραψε:

> Hi,
> Thank you all for guiding me to the solution especially "Numa" .. and this
> is how I solved it:
> for the .tml
> 
>
> and in the JS JQuery file, I passed the variable in a JSON object --> data:
> {myData:dataToSend}
> $('#myId').click(function() {
> var dataToSend=  $('#myId').data('mydata');
> ajax('answer', {
> element: $('#myId'),
> data:{ myData:dataToSend},
> success: function(response) {
> }
> });
> });
>
> and in java file, I used @RequestParameter("myData") to get the value from
> the JSON object:
>  @OnEvent("answer")
>  @PublishEvent
> public void answer(@RequestParameter("myData") String varName)
> {
> System.out.println("Variable name is :"+  varName  );
> }
>
> Regards,
> Marwa
>
>
> On Tue, Aug 28, 2018 at 3:20 PM Numa Schmeder  wrote:
>
> > Hello Marwa,
> >
> > The answer provided by Thiago is much simpler.
> > Just put your data in a data attribute of a tag and then use the tutorial
> > ajax and zones to send this data to a server side event handler.
> > If you want to do it automatically without triggering a javascript event,
> > just put you script in an on document ready event, to make sure your
> > javascript code is called once the page is rendered and loaded by the
> > browser.
> >
> >
> > ===> in html page
> >
> > 
> >
> > ===> javascript at the end of html page
> >
> > $(function() {
> > var dataToSend = $(‘#myId’).data(‘mydata’);
> > ajax(‘pageData', {
> > data: dataToSend, // This doesn't need to be the
> > same element as the one two lines above
> > // Callback called when the request is finished.
> > // response.json is the object returned by the event handler
> > method
> > success: function(response) {
> > alert('sent to server');
> > }
> > });
> > });
> >
> >
> > => in java page
> >
> > JSONObject onPageData()
> > {
> > return new JSONObject("origin", "componentAction");
> > }
> >
> >
> > You can use jquery or something else.
> >
> > Best
> > Numa
> >
> >
> >
> >   <http://www.dfacto.ch/>   Numa Schmederwww.dfacto.ch  <
> > http://www.dfacto.ch/>
> > n...@dfacto.ch <mailto:n...@dfacto.ch>   |   M +41 79 538 30 01
> >
> > DIGITAL STRATEGY   |   DESIGN   |   DEVELOPMENT
> >
> >
> >
> >
> > > Le 28 août 2018 à 12:22, marwa hussein  a
> > écrit :
> > >
> > > Hello,
> > >
> > > Thanks all for your suggestions. I followed the example shown in
> > > https://tapestry.apache.org/ajax-and-zones.html in "Invoking
> server-side
> > > event handler methods from JavaScript"   but here the event is in the
> > java
> > > code "server-side" and is invoked from the Javascript code "onClick()"
> ,
> > > but what I want is the opposite direction, sending a "string variable"
> > from
> > > a tag appended in  the clientside javascript code to the java code "in
> > the
> > > serverside".
> > > For now, I will test to use hidden input (although I didn't want to
> use a
> > > form submit) and I will see if I can make it or not ...
> > >
> > > Thank you all for your help and valuable suggestions, and of course, if
> > > anyone face the same problem before and could give me hints to how to
> do
> > it
> > > please tell me.
> > > Regards,
> > > Marwa
> >
> >
>
> --
>
>
>
> *Marwa Hussein M. TA @ Information Systems Department Faculty of Computers
> & Information Assuit University*
> 
>


Re: How to pass a variable from Javascript code to Java

2018-08-29 Thread marwa hussein
Hi,
Thank you all for guiding me to the solution especially "Numa" .. and this
is how I solved it:
for the .tml


and in the JS JQuery file, I passed the variable in a JSON object --> data:
{myData:dataToSend}
$('#myId').click(function() {
var dataToSend=  $('#myId').data('mydata');
ajax('answer', {
element: $('#myId'),
data:{ myData:dataToSend},
success: function(response) {
}
});
});

and in java file, I used @RequestParameter("myData") to get the value from
the JSON object:
 @OnEvent("answer")
 @PublishEvent
public void answer(@RequestParameter("myData") String varName)
{
System.out.println("Variable name is :"+  varName  );
}

Regards,
Marwa


On Tue, Aug 28, 2018 at 3:20 PM Numa Schmeder  wrote:

> Hello Marwa,
>
> The answer provided by Thiago is much simpler.
> Just put your data in a data attribute of a tag and then use the tutorial
> ajax and zones to send this data to a server side event handler.
> If you want to do it automatically without triggering a javascript event,
> just put you script in an on document ready event, to make sure your
> javascript code is called once the page is rendered and loaded by the
> browser.
>
>
> ===> in html page
>
> 
>
> ===> javascript at the end of html page
>
> $(function() {
> var dataToSend = $(‘#myId’).data(‘mydata’);
> ajax(‘pageData', {
> data: dataToSend, // This doesn't need to be the
> same element as the one two lines above
> // Callback called when the request is finished.
> // response.json is the object returned by the event handler
> method
> success: function(response) {
> alert('sent to server');
> }
> });
> });
>
>
> => in java page
>
> JSONObject onPageData()
> {
> return new JSONObject("origin", "componentAction");
> }
>
>
> You can use jquery or something else.
>
> Best
> Numa
>
>
>
>   <http://www.dfacto.ch/>   Numa Schmederwww.dfacto.ch  <
> http://www.dfacto.ch/>
> n...@dfacto.ch <mailto:n...@dfacto.ch>   |   M +41 79 538 30 01
>
> DIGITAL STRATEGY   |   DESIGN   |   DEVELOPMENT
>
>
>
>
> > Le 28 août 2018 à 12:22, marwa hussein  a
> écrit :
> >
> > Hello,
> >
> > Thanks all for your suggestions. I followed the example shown in
> > https://tapestry.apache.org/ajax-and-zones.html in "Invoking server-side
> > event handler methods from JavaScript"   but here the event is in the
> java
> > code "server-side" and is invoked from the Javascript code "onClick()" ,
> > but what I want is the opposite direction, sending a "string variable"
> from
> > a tag appended in  the clientside javascript code to the java code "in
> the
> > serverside".
> > For now, I will test to use hidden input (although I didn't want to use a
> > form submit) and I will see if I can make it or not ...
> >
> > Thank you all for your help and valuable suggestions, and of course, if
> > anyone face the same problem before and could give me hints to how to do
> it
> > please tell me.
> > Regards,
> > Marwa
>
>

-- 



*Marwa Hussein M. TA @ Information Systems Department Faculty of Computers
& Information Assuit University*



Re: How to pass a variable from Javascript code to Java

2018-08-28 Thread Numa Schmeder
Hello Marwa,

The answer provided by Thiago is much simpler. 
Just put your data in a data attribute of a tag and then use the tutorial ajax 
and zones to send this data to a server side event handler. 
If you want to do it automatically without triggering a javascript event, just 
put you script in an on document ready event, to make sure your javascript code 
is called once the page is rendered and loaded by the browser. 


===> in html page



===> javascript at the end of html page

$(function() {
var dataToSend = $(‘#myId’).data(‘mydata’);
ajax(‘pageData', { 
data: dataToSend, // This doesn't need to be the same 
element as the one two lines above
// Callback called when the request is finished. 
// response.json is the object returned by the event handler method
success: function(response) {
alert('sent to server');
}
});
});


=> in java page

JSONObject onPageData()
{
return new JSONObject("origin", "componentAction");
}  


You can use jquery or something else.

Best
Numa



  <http://www.dfacto.ch/>   Numa Schmederwww.dfacto.ch  
<http://www.dfacto.ch/>
n...@dfacto.ch <mailto:n...@dfacto.ch>   |   M +41 79 538 30 01 

DIGITAL STRATEGY   |   DESIGN   |   DEVELOPMENT


 

> Le 28 août 2018 à 12:22, marwa hussein  a écrit :
> 
> Hello,
> 
> Thanks all for your suggestions. I followed the example shown in
> https://tapestry.apache.org/ajax-and-zones.html in "Invoking server-side
> event handler methods from JavaScript"   but here the event is in the java
> code "server-side" and is invoked from the Javascript code "onClick()" ,
> but what I want is the opposite direction, sending a "string variable" from
> a tag appended in  the clientside javascript code to the java code "in the
> serverside".
> For now, I will test to use hidden input (although I didn't want to use a
> form submit) and I will see if I can make it or not ...
> 
> Thank you all for your help and valuable suggestions, and of course, if
> anyone face the same problem before and could give me hints to how to do it
> please tell me.
> Regards,
> Marwa



Re: How to pass a variable from Javascript code to Java

2018-08-28 Thread marwa hussein
Hello,

Thanks all for your suggestions. I followed the example shown in
https://tapestry.apache.org/ajax-and-zones.html in "Invoking server-side
event handler methods from JavaScript"   but here the event is in the java
code "server-side" and is invoked from the Javascript code "onClick()" ,
but what I want is the opposite direction, sending a "string variable" from
a tag appended in  the clientside javascript code to the java code "in the
serverside".
For now, I will test to use hidden input (although I didn't want to use a
form submit) and I will see if I can make it or not ...

Thank you all for your help and valuable suggestions, and of course, if
anyone face the same problem before and could give me hints to how to do it
please tell me.
Regards,
Marwa


Re: How to pass a variable from Javascript code to Java

2018-08-27 Thread Thiago H. de Paula Figueiredo
I've just noticed Peter had already posted the same answer as me. I'm sorry.

On Mon, Aug 27, 2018 at 3:24 PM Thiago H. de Paula Figueiredo <
thiag...@gmail.com> wrote:

> On Sat, Aug 25, 2018 at 3:33 AM marwa hussein 
> wrote:
>
>> Hello,
>
>
> Hi!
>
>
>> I am building a web application and I have to use an open source
>> Javascript package that is responsible for the visualization tasks. Now, I
>> need to pass a "string variable" from the javascript code to the java
>> code?? how to do this in tapestry5 ..Please refer me to a working example
>> if you can!!
>>
>
> Just use HTML's data attributes, just as Tapestry 5.4+ itself does. For
> example, supposing the div below is one which already exists in your page:
>
> 
>
> Then, in your Java code, you compute the visualization data:
>
> public String getVisualizationData() {
> ...
> return data;
> }
>
> Then, in your JavaScript, supposing you're using jQuery:
>
> var visualizationData = $('#visualization').attr('visualization-data');
>
> Notice the code above isn't tested. Of course, feel free to adapt it to
> your existing code.
>
> --
> Thiago
>


-- 
Thiago


Re: How to pass a variable from Javascript code to Java

2018-08-27 Thread Thiago H. de Paula Figueiredo
Hello!

See the Invoking server-side event handler methods from JavaScript in
https://tapestry.apache.org/ajax-and-zones.html. It has an example of how
to do it in Tapestry 5.4.2+. There's no easy way of doing it than this.

On Mon, Aug 27, 2018 at 4:47 AM  wrote:

> Hi Marwa,
>
> there is an example in the bottom part of this page
>
> https://tapestry.apache.org/ajax-and-zones.html
>
> which you can use for your development. The paragraph "Invoking
> server-side event
> handler methods from JavaScript" contains the corresponding explanation.
>
> If you do not want to use zones and asynchronous requests, you cat use a
> hidden field
> to transfer the value to java.
> The hidden field hast to be contained in a form. You put the value with
> java script in
> the hidden field. With a form submit it will be transferred to java.
>
> Sorry that I am not referencing to an example, but possibly you manage it
> even with
> this information..
>
> With regards, Peter
>
>
> > Thanks for your replay but actually I scanned all the links and I
> couldn't
> > find an answer for my issue... Let me explain it in more details ..in the
> > .tml code I have this line
> > Name: 
> > and in the javascript code, there is a function that calculates the
> "name"
> > for this element and another that creates a link containing the name of
> > this element to be displayed as a link.
> >
> > function appendIriLabel(element, name, iri) {
> > var tag;
> > if (iri) {
> > tag = element.append("a")
> > .attr("href", iri)
> > .attr("title", iri)
> > .attr("target", "_blank");
> > } else {
> > tag = element.append("span");
> > }
> > tag.text(name);
> > }
> >
> > and what I need is to pass the string variable "name" from the client
> side
> > javascriptcode, to the java code in order to use it in the server side
> > functions.
> > How to make this?
> >
> > Hope I could illustrate my problem well ...
> >
> >
> > On Sun, Aug 26, 2018 at 12:00 PM Basile Chandesris 
> wrote:
> >
> >> Le 25/08/2018 à 08:32, marwa hussein a écrit :
> >> > Hello, I am building a web application and I have to use an open
> source
> >> > Javascript package that is responsible for the visualization tasks.
> Now,
> >> I
> >> > need to pass a "string variable" from the javascript code to the java
> >> > code?? how to do this in tapestry5 ..Please refer me to a working
> example
> >> > if you can!!
> >> >
> >> >
> >>
> >>
> http://jumpstart.doublenegative.com.au/jumpstart/examples/javascript/javascript
> >>
> >> https://tapestry.apache.org/legacy-javascript.html
> >>
> >> https://tapestry.apache.org/javascript.html
> >>
> >>
> >>
> >> http://tapestry5-jquery.com/
> >>
> >> https://github.com/ffacon/tapestry5-angular-demo
> >>
> >> https://github.com/eddyson-de/tapestry-react
> >>
> >> https://tapestry.apache.org/coffeescript.html
> >>
> >>
> >>
> >>
> >
> > --
> >
> >
> >
> > *Marwa Hussein M. TA @ Information Systems Department Faculty of
> Computers
> > & Information Assuit University*
> > 
> >
>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

-- 
Thiago


Re: How to pass a variable from Javascript code to Java

2018-08-27 Thread Thiago H. de Paula Figueiredo
On Sat, Aug 25, 2018 at 3:33 AM marwa hussein 
wrote:

> Hello,


Hi!


> I am building a web application and I have to use an open source
> Javascript package that is responsible for the visualization tasks. Now, I
> need to pass a "string variable" from the javascript code to the java
> code?? how to do this in tapestry5 ..Please refer me to a working example
> if you can!!
>

Just use HTML's data attributes, just as Tapestry 5.4+ itself does. For
example, supposing the div below is one which already exists in your page:



Then, in your Java code, you compute the visualization data:

public String getVisualizationData() {
...
return data;
}

Then, in your JavaScript, supposing you're using jQuery:

var visualizationData = $('#visualization').attr('visualization-data');

Notice the code above isn't tested. Of course, feel free to adapt it to
your existing code.

-- 
Thiago


Re: How to pass a variable from Javascript code to Java

2018-08-27 Thread peter . skala
Hi Marwa,

there is an example in the bottom part of this page

https://tapestry.apache.org/ajax-and-zones.html

which you can use for your development. The paragraph "Invoking server-side 
event
handler methods from JavaScript" contains the corresponding explanation.

If you do not want to use zones and asynchronous requests, you cat use a hidden 
field
to transfer the value to java.
The hidden field hast to be contained in a form. You put the value with java 
script in
the hidden field. With a form submit it will be transferred to java.

Sorry that I am not referencing to an example, but possibly you manage it even 
with
this information..

With regards, Peter


> Thanks for your replay but actually I scanned all the links and I couldn't
> find an answer for my issue... Let me explain it in more details ..in the
> .tml code I have this line
> Name: 
> and in the javascript code, there is a function that calculates the "name"
> for this element and another that creates a link containing the name of
> this element to be displayed as a link.
>
> function appendIriLabel(element, name, iri) {
> var tag;
> if (iri) {
> tag = element.append("a")
> .attr("href", iri)
> .attr("title", iri)
> .attr("target", "_blank");
> } else {
> tag = element.append("span");
> }
> tag.text(name);
> }
>
> and what I need is to pass the string variable "name" from the client side
> javascriptcode, to the java code in order to use it in the server side
> functions.
> How to make this?
>
> Hope I could illustrate my problem well ...
>
>
> On Sun, Aug 26, 2018 at 12:00 PM Basile Chandesris  wrote:
>
>> Le 25/08/2018 à 08:32, marwa hussein a écrit :
>> > Hello, I am building a web application and I have to use an open source
>> > Javascript package that is responsible for the visualization tasks. Now,
>> I
>> > need to pass a "string variable" from the javascript code to the java
>> > code?? how to do this in tapestry5 ..Please refer me to a working example
>> > if you can!!
>> >
>> >
>>
>> http://jumpstart.doublenegative.com.au/jumpstart/examples/javascript/javascript
>>
>> https://tapestry.apache.org/legacy-javascript.html
>>
>> https://tapestry.apache.org/javascript.html
>>
>>
>>
>> http://tapestry5-jquery.com/
>>
>> https://github.com/ffacon/tapestry5-angular-demo
>>
>> https://github.com/eddyson-de/tapestry-react
>>
>> https://tapestry.apache.org/coffeescript.html
>>
>>
>>
>>
>
> --
>
>
>
> *Marwa Hussein M. TA @ Information Systems Department Faculty of Computers
> & Information Assuit University*
> 
>



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



Re: How to pass a variable from Javascript code to Java

2018-08-26 Thread marwa hussein
Thanks for your replay but actually I scanned all the links and I couldn't
find an answer for my issue... Let me explain it in more details ..in the
.tml code I have this line
Name: 
and in the javascript code, there is a function that calculates the "name"
for this element and another that creates a link containing the name of
this element to be displayed as a link.

function appendIriLabel(element, name, iri) {
var tag;
if (iri) {
tag = element.append("a")
.attr("href", iri)
.attr("title", iri)
.attr("target", "_blank");
} else {
tag = element.append("span");
}
tag.text(name);
}

and what I need is to pass the string variable "name" from the client side
javascriptcode, to the java code in order to use it in the server side
functions.
How to make this?

Hope I could illustrate my problem well ...


On Sun, Aug 26, 2018 at 12:00 PM Basile Chandesris  wrote:

> Le 25/08/2018 à 08:32, marwa hussein a écrit :
> > Hello, I am building a web application and I have to use an open source
> > Javascript package that is responsible for the visualization tasks. Now,
> I
> > need to pass a "string variable" from the javascript code to the java
> > code?? how to do this in tapestry5 ..Please refer me to a working example
> > if you can!!
> >
> >
>
> http://jumpstart.doublenegative.com.au/jumpstart/examples/javascript/javascript
>
> https://tapestry.apache.org/legacy-javascript.html
>
> https://tapestry.apache.org/javascript.html
>
>
>
> http://tapestry5-jquery.com/
>
> https://github.com/ffacon/tapestry5-angular-demo
>
> https://github.com/eddyson-de/tapestry-react
>
> https://tapestry.apache.org/coffeescript.html
>
>
>
>

-- 



*Marwa Hussein M. TA @ Information Systems Department Faculty of Computers
& Information Assuit University*



How to pass a variable from Javascript code to Java

2018-08-24 Thread marwa hussein
Hello, I am building a web application and I have to use an open source
Javascript package that is responsible for the visualization tasks. Now, I
need to pass a "string variable" from the javascript code to the java
code?? how to do this in tapestry5 ..Please refer me to a working example
if you can!!


-- 



*Marwa Hussein M. TA @ Information Systems Department Faculty of Computers
& Information Assuit University*



Re: [Announcement] New feature for Tapestry 5.4.2 and 5.5: easily call event handler methods from JavaScript

2017-04-27 Thread abangkis
Yes. I've seen it. Pretty clean and good example.

Thank you.

On Thu, Apr 27, 2017 at 7:15 PM, Svein-Erik Løken  wrote:

> See my working demo above in this thread:
> (https://github.com/sveine/tapestry-multi-module-demo/
> blob/master/module1-root/module1/src/main/resources/META-INF/modules/
> publisheventdemo.js)
>
> From: Thiago H de Paula Figueiredo [via Apache Tapestry Mailing List
> Archives] [mailto:ml+s1045711n5733456...@n5.nabble.com]
> Sent: 27. april 2017 14:11
> To: Svein-Erik Løken 
> Subject: Re: [Announcement] New feature for Tapestry 5.4.2 and 5.5: easily
> call event handler methods from JavaScript
>
> On Thu, Apr 27, 2017 at 6:43 AM, abangkis <[hidden
> email]> wrote:
>
> > Hi. Thanks for the awesome improvement. I want to adopt it immediately.
>
>
> Hi! Nice! :)
>
>
> > But I've stumbled to one problem. How do I pass a parameter to the event?
> >
>
> You don't pass it to the event, but to the t5/core/ajax() function. Check
> the data property of the options parameter in
> https://tapestry.apache.org/current/coffeescript/ajax.html. Basically, you
> pass an object with the key/value pairs you want passed as parameters:
>
> ajax('answer', {
> element: $('#result'),
> /* Here it goes */
> data: {
> queryParameter1: valueParameter1,
> queryParameter2: valueParameter2
> }
> /* Here it ends */
> success: function(response) {
> $('#result').text(response.json.origin);
> }
> });
>
>
> --
> Thiago
>
> 
> If you reply to this email, your message will be added to the discussion
> below:
> http://apache-tapestry-mailing-list-archives.1045711.
> n5.nabble.com/Announcement-New-feature-for-Tapestry-5-4-
> 2-and-5-5-easily-call-event-handler-methods-from-
> JavaScript-tp5733295p5733456.html
> To unsubscribe from users@tapestry.apache.org users@tapestry.apache.org> Mailing List Archives, click here<
> http://apache-tapestry-mailing-list-archives.1045711.
> n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=
> 2375125&code=c3ZlaW5AamFjaWxsYS5ub3wyMzc1MTI1fC0xNTM4NzY2ODg4>.
> NAML<http://apache-tapestry-mailing-list-archives.1045711.
> n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%
> 21nabble%3Aemail.naml&base=nabble.naml.namespaces.
> BasicNamespace-nabble.view.web.template.NabbleNamespace-
> nabble.view.web.template.NodeNamespace&breadcrumbs=
> notify_subscribers%21nabble%3Aemail.naml-instant_emails%
> 21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
http://www.mreunionlabs.net/ <http://www.mreunion-labs.net/>
twitter : @mreunionlabs @abangkis
page : https://plus.google.com/104168782385184990771


Re: [Announcement] New feature for Tapestry 5.4.2 and 5.5: easily call event handler methods from JavaScript

2017-04-27 Thread abangkis
Thank you very much. I got it working. Now my code is going to be a whole
lot cleaner.

Good job Thiago.

On Thu, Apr 27, 2017 at 7:10 PM, Thiago H. de Paula Figueiredo <
thiag...@gmail.com> wrote:

> On Thu, Apr 27, 2017 at 6:43 AM, abangkis  wrote:
>
> > Hi. Thanks for the awesome improvement. I want to adopt it immediately.
>
>
> Hi! Nice! :)
>
>
> > But I've stumbled to one problem. How do I pass a parameter to the event?
> >
>
> You don't pass it to the event, but to the t5/core/ajax() function. Check
> the data property of the options parameter in
> https://tapestry.apache.org/current/coffeescript/ajax.html. Basically, you
> pass an object with the key/value pairs you want passed as parameters:
>
> ajax('answer', {
> element: $('#result'),
> /* Here it goes */
> data: {
> queryParameter1: valueParameter1,
> queryParameter2: valueParameter2
> }
> /* Here it ends */
> success: function(response) {
> $('#result').text(response.json.origin);
> }
> });
>
>
> --
> Thiago
>



-- 
http://www.mreunionlabs.net/ 
twitter : @mreunionlabs @abangkis
page : https://plus.google.com/104168782385184990771


RE: [Announcement] New feature for Tapestry 5.4.2 and 5.5: easily call event handler methods from JavaScript

2017-04-27 Thread Svein-Erik Løken
See my working demo above in this thread:
(https://github.com/sveine/tapestry-multi-module-demo/blob/master/module1-root/module1/src/main/resources/META-INF/modules/publisheventdemo.js)

From: Thiago H de Paula Figueiredo [via Apache Tapestry Mailing List Archives] 
[mailto:ml+s1045711n5733456...@n5.nabble.com]
Sent: 27. april 2017 14:11
To: Svein-Erik Løken 
Subject: Re: [Announcement] New feature for Tapestry 5.4.2 and 5.5: easily call 
event handler methods from JavaScript

On Thu, Apr 27, 2017 at 6:43 AM, abangkis <[hidden 
email]> wrote:

> Hi. Thanks for the awesome improvement. I want to adopt it immediately.


Hi! Nice! :)


> But I've stumbled to one problem. How do I pass a parameter to the event?
>

You don't pass it to the event, but to the t5/core/ajax() function. Check
the data property of the options parameter in
https://tapestry.apache.org/current/coffeescript/ajax.html. Basically, you
pass an object with the key/value pairs you want passed as parameters:

ajax('answer', {
element: $('#result'),
/* Here it goes */
data: {
queryParameter1: valueParameter1,
queryParameter2: valueParameter2
}
/* Here it ends */
success: function(response) {
$('#result').text(response.json.origin);
}
});


--
Thiago


If you reply to this email, your message will be added to the discussion below:
http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/Announcement-New-feature-for-Tapestry-5-4-2-and-5-5-easily-call-event-handler-methods-from-JavaScript-tp5733295p5733456.html
To unsubscribe from users@tapestry.apache.org<mailto:users@tapestry.apache.org> 
Mailing List Archives, click 
here<http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2375125&code=c3ZlaW5AamFjaWxsYS5ub3wyMzc1MTI1fC0xNTM4NzY2ODg4>.
NAML<http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>


Re: [Announcement] New feature for Tapestry 5.4.2 and 5.5: easily call event handler methods from JavaScript

2017-04-27 Thread Thiago H. de Paula Figueiredo
On Thu, Apr 27, 2017 at 6:43 AM, abangkis  wrote:

> Hi. Thanks for the awesome improvement. I want to adopt it immediately.


Hi! Nice! :)


> But I've stumbled to one problem. How do I pass a parameter to the event?
>

You don't pass it to the event, but to the t5/core/ajax() function. Check
the data property of the options parameter in
https://tapestry.apache.org/current/coffeescript/ajax.html. Basically, you
pass an object with the key/value pairs you want passed as parameters:

ajax('answer', {
element: $('#result'),
/* Here it goes */
data: {
queryParameter1: valueParameter1,
queryParameter2: valueParameter2
}
/* Here it ends */
success: function(response) {
$('#result').text(response.json.origin);
}
});


-- 
Thiago


Re: [Announcement] New feature for Tapestry 5.4.2 and 5.5: easily call event handler methods from JavaScript

2017-04-27 Thread abangkis
Hi. Thanks for the awesome improvement. I want to adopt it immediately. But
I've stumbled to one problem. How do I pass a parameter to the event?

Here's the onEvent method that will be invoked

@OnEvent("updateNodes")
void updateNodes(@RequestParameter(value = "param", allowBlank = false)
String param) {
logger.debug("On update nodes {} ", param);
}

In the old way i could call it using

$('#saveChanges').click(function () {
var my_param = {'example param'};

routejs.jsClickCallback(tSpec.updateOrderEventLink, tSpec.zoneId,
JSON.stringify(my_param));
});

var jsClickCallback = function(listenerURI, zoneElementId, param) {
  var listenerURIWithValue = listenerURI;

  listenerURIWithValue = appendQueryStringParameter(listenerURIWithValue,
'param', param);

  zoneManager.deferredZoneUpdate(zoneElementId, listenerURIWithValue);
};

var appendQueryStringParameter = function(url, name, value) {
  if (url.indexOf('?') < 0) {
url += '?'
  }
  else {
url += '&';
  }
  value = escape(value);
  url += name + '=' + value;
  return url;
}

On Sun, Apr 23, 2017 at 6:04 AM, Thiago H. de Paula Figueiredo <
thiag...@gmail.com> wrote:

> Cool! It's nice to see a feature I've wanted for so long already being
> adopted by users. Thanks for the example!
>
> On Fri, Apr 21, 2017 at 11:18 AM, Svein-Erik Løken 
> wrote:
>
> > The @PublishEvent was a big improvement 😊
> >
> >
> >
> > I am using it already. I have created a working demo. I really like that
> > it is so easy to stop hardcoding of event url.
> >
> >
> >
> >
> >
> > https://github.com/sveine/tapestry-multi-module-demo/
> > blob/master/module1-root/module1/src/main/java/com/demo/module1/pages/
> > PublishEventDemo.java
> >
> > https://github.com/sveine/tapestry-multi-module-demo/
> > blob/master/module1-root/module1/src/main/resources/
> > com/demo/module1/pages/PublishEventDemo.tml
> >
> > https://github.com/sveine/tapestry-multi-module-demo/
> > blob/master/module1-root/module1/src/main/resources/META-INF/modules/
> > publisheventdemo.js
> >
> > https://github.com/sveine/tapestry-multi-module-demo/
> > blob/master/core/src/main/resources/META-INF/modules/
> util/tapestryutil.js
> > (TapestryUtil.ajaxEvent)
> >
>
>
>
> --
> Thiago
>



-- 
http://www.mreunionlabs.net/ 
twitter : @mreunionlabs @abangkis
page : https://plus.google.com/104168782385184990771


Re: [Announcement] New feature for Tapestry 5.4.2 and 5.5: easily call event handler methods from JavaScript

2017-04-22 Thread Thiago H. de Paula Figueiredo
Cool! It's nice to see a feature I've wanted for so long already being
adopted by users. Thanks for the example!

On Fri, Apr 21, 2017 at 11:18 AM, Svein-Erik Løken  wrote:

> The @PublishEvent was a big improvement 😊
>
>
>
> I am using it already. I have created a working demo. I really like that
> it is so easy to stop hardcoding of event url.
>
>
>
>
>
> https://github.com/sveine/tapestry-multi-module-demo/
> blob/master/module1-root/module1/src/main/java/com/demo/module1/pages/
> PublishEventDemo.java
>
> https://github.com/sveine/tapestry-multi-module-demo/
> blob/master/module1-root/module1/src/main/resources/
> com/demo/module1/pages/PublishEventDemo.tml
>
> https://github.com/sveine/tapestry-multi-module-demo/
> blob/master/module1-root/module1/src/main/resources/META-INF/modules/
> publisheventdemo.js
>
> https://github.com/sveine/tapestry-multi-module-demo/
> blob/master/core/src/main/resources/META-INF/modules/util/tapestryutil.js
> (TapestryUtil.ajaxEvent)
>



-- 
Thiago


RE: [Announcement] New feature for Tapestry 5.4.2 and 5.5: easily call event handler methods from JavaScript

2017-04-21 Thread Svein-Erik Løken
The @PublishEvent was a big improvement 😊



I am using it already. I have created a working demo. I really like that it is 
so easy to stop hardcoding of event url.





https://github.com/sveine/tapestry-multi-module-demo/blob/master/module1-root/module1/src/main/java/com/demo/module1/pages/PublishEventDemo.java

https://github.com/sveine/tapestry-multi-module-demo/blob/master/module1-root/module1/src/main/resources/com/demo/module1/pages/PublishEventDemo.tml

https://github.com/sveine/tapestry-multi-module-demo/blob/master/module1-root/module1/src/main/resources/META-INF/modules/publisheventdemo.js

https://github.com/sveine/tapestry-multi-module-demo/blob/master/core/src/main/resources/META-INF/modules/util/tapestryutil.js
 (TapestryUtil.ajaxEvent)


[Announcement] New feature for Tapestry 5.4.2 and 5.5: easily call event handler methods from JavaScript

2017-03-19 Thread Thiago H. de Paula Figueiredo
Hi!

This is something I've wanted for a really long time to implement in
Tapestry, so I won't wait for it to be released or even the documentation
to be updated in the site to post it here. Feedback welcome!
Invoking server-side event handler methods from JavaScript

Tapestry 5.4.2 introduced has an API which makes it easy for server-side
events to be invoked from JavaScript. In the server-side, you first need to
annotate the event handler methods you want exposed with the new
@PublishEvent annotation. Then, in JavaScript, all you need to do is to
call the existing t5/core/ajax
<http://tapestry.apache.org/current/coffeescript/ajax.html> function but
with slightly different parameters.

t5/core/ajax has two parameters: url and options. The first one was the
difficult part to get when doing AJAX requests to event handler methods in
Tapestry. You needed to inject ComponentResources, call
componentResources.createEventLink() for each event handler method then
pass all this information to JS through one of the JavaScriptSupport methods.
Since 5.4.2, your JavaScript code only needs to know the event name (also
called *event type*) and optionally indicate a DOM element to be used as a
starting point for finding the event URL.

All event data is stored in data-componenent-events attributes. For page
classes, it's put in the  element. For components, it's put in the
first element rendered created by rendering the component. Given an HTML
element, the search is done until one in this order until information for
the given event is first found:

   1. The element itself
   2. The element's previous siblings, closest first (bottom-up)
   3. The element's parents.
   4. The page's  element.



Here's one example:
public class PublishEventDemoComponent
{
@OnEvent("answer")
@PublishEvent
JSONObject answer() {
return new JSONObject("origin", "componentAnswer");
}

@PublishEvent
JSONObject onAction()
{
return new JSONObject("origin", "componentAction");
}
}

Notice that answer() and onAction() are ordinary event handlers, with
nothing specific besides the @PublishEvent annotation.
http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";
<http://tapestry.apache.org/schema/tapestry_5_0_0.xsd>>
I'm a component
(no result yet)


The template also has nothing special. When rendered, the component's
events information is placed in the outer  (id="component").

We want to update the text of  with the value of the
origin property
of the returned JSON object when that element itself is clicked, so here's
our JavaScript code, supposing we want to trigger the answer event:
1
2
3
4
5
6
7
8
9
10
11
12
13
require(["t5/core/ajax", "jquery"], function (ajax, $) {
// Creating a callback to be invoked with  is clicked.
$('#result').click(function() {
ajax('answer', {
element: $('#result'), // This doesn't need to be the same
element as the one two lines above
// Callback called when the request is finished.
// response.json is the object returned by the event handler
method
success: function(response) {
$('#result').text(response.json.origin);
}
});
});
});

If you're trying to invoke a page class event handler, you can change line
5 above to element: null. You do need to explicitly set the element property,
otherwise the ajax function will treat the first parameter, url, as an URL
and not as an event name.

-- 
Thiago


Re: Add javascript every request

2016-12-07 Thread Nathan Quirynen
Would this cover all requests? My application uses a lot of ajax, so 
preferably the countdown script would reset on every request (xhr or non 
xhr) right?



On 07/12/16 12:47, Thiago H. de Paula Figueiredo wrote:

Hi!

Another solution, specially if you don't have a single layout component for
all the pages, would be creating a mixin to include the JavaScript you
want, plus implementing and contributing a ComponentClassTransformWorker to
apply it to all pages. I can provide you examples if you want.

On Wed, Dec 7, 2016 at 9:20 AM, David Diaz  wrote:


Hi Nathan,

You can use a  in your main Layout.tml.

For example, in your Layout.tml

http://tapestry.apache.org/schema/tapestry_5_4_1.xsd";>
 
 
 


Then in your Layout.java

public void onSessionTimeout()
{
  ajaxResponseRenderer.addCallback(**do callback stuff here**);
}

I've implemented this in my application - if you need more help, ill be
happy to help!

Thanks,
David.

On Wed, Dec 7, 2016 at 9:26 PM, Nathan Quirynen <
nat...@pensionarchitects.be

wrote:
Hi,

I want to add a session timeout warning popup to a Tapestry5.4
application. I thought of creating a javascript module that counts down

the

remaining time left before the session times out and then shows a popup
warning with the option to logout or keep on going and if no action is
taken automatically logs out the user. But I'm not sure where/when I
can/should add this javascript module to the response. I think I need to
start or reset this count down every request (normal and xhr) as this
"resets" the sessions timeout and maybe exclude some pages that have a
specific annotation (NoSessionRequired). I thought of implementing a
component request filter to solve this, but there's no JavaScriptSupport
available there. How can I do this?

Nathan


-
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: Add javascript every request

2016-12-07 Thread Thiago H. de Paula Figueiredo
Hi!

Another solution, specially if you don't have a single layout component for
all the pages, would be creating a mixin to include the JavaScript you
want, plus implementing and contributing a ComponentClassTransformWorker to
apply it to all pages. I can provide you examples if you want.

On Wed, Dec 7, 2016 at 9:20 AM, David Diaz  wrote:

> Hi Nathan,
>
> You can use a  in your main Layout.tml.
>
> For example, in your Layout.tml
>
> http://tapestry.apache.org/schema/tapestry_5_4_1.xsd";>
> 
> 
> 
> 
>
> Then in your Layout.java
>
> public void onSessionTimeout()
> {
>  ajaxResponseRenderer.addCallback(**do callback stuff here**);
> }
>
> I've implemented this in my application - if you need more help, ill be
> happy to help!
>
> Thanks,
> David.
>
> On Wed, Dec 7, 2016 at 9:26 PM, Nathan Quirynen <
> nat...@pensionarchitects.be
> > wrote:
>
> > Hi,
> >
> > I want to add a session timeout warning popup to a Tapestry5.4
> > application. I thought of creating a javascript module that counts down
> the
> > remaining time left before the session times out and then shows a popup
> > warning with the option to logout or keep on going and if no action is
> > taken automatically logs out the user. But I'm not sure where/when I
> > can/should add this javascript module to the response. I think I need to
> > start or reset this count down every request (normal and xhr) as this
> > "resets" the sessions timeout and maybe exclude some pages that have a
> > specific annotation (NoSessionRequired). I thought of implementing a
> > component request filter to solve this, but there's no JavaScriptSupport
> > available there. How can I do this?
> >
> > Nathan
> >
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> > For additional commands, e-mail: users-h...@tapestry.apache.org
> >
> >
>



-- 
Thiago


Re: Add javascript every request

2016-12-07 Thread David Diaz
Hi Nathan,

You can use a  in your main Layout.tml.

For example, in your Layout.tml

http://tapestry.apache.org/schema/tapestry_5_4_1.xsd";>





Then in your Layout.java

public void onSessionTimeout()
{
 ajaxResponseRenderer.addCallback(**do callback stuff here**);
}

I've implemented this in my application - if you need more help, ill be
happy to help!

Thanks,
David.

On Wed, Dec 7, 2016 at 9:26 PM, Nathan Quirynen  wrote:

> Hi,
>
> I want to add a session timeout warning popup to a Tapestry5.4
> application. I thought of creating a javascript module that counts down the
> remaining time left before the session times out and then shows a popup
> warning with the option to logout or keep on going and if no action is
> taken automatically logs out the user. But I'm not sure where/when I
> can/should add this javascript module to the response. I think I need to
> start or reset this count down every request (normal and xhr) as this
> "resets" the sessions timeout and maybe exclude some pages that have a
> specific annotation (NoSessionRequired). I thought of implementing a
> component request filter to solve this, but there's no JavaScriptSupport
> available there. How can I do this?
>
> Nathan
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Add javascript every request

2016-12-07 Thread Nathan Quirynen

Hi,

I want to add a session timeout warning popup to a Tapestry5.4 
application. I thought of creating a javascript module that counts down 
the remaining time left before the session times out and then shows a 
popup warning with the option to logout or keep on going and if no 
action is taken automatically logs out the user. But I'm not sure 
where/when I can/should add this javascript module to the response. I 
think I need to start or reset this count down every request (normal and 
xhr) as this "resets" the sessions timeout and maybe exclude some pages 
that have a specific annotation (NoSessionRequired). I thought of 
implementing a component request filter to solve this, but there's no 
JavaScriptSupport available there. How can I do this?


Nathan


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



RE: Javascript function not present in html source

2016-11-04 Thread Lherm Nicolas


RE: Javascript function not present in html source

2016-11-02 Thread Lherm Nicolas


Re: Javascript function not present in html source

2016-11-02 Thread Cezary Biernacki
Hi Nicolas,
are you sure that the string you observed "" is actually sent from the server, not
result of manipulation of some JavaScript later? I do not see any reason
for Tapestry to render your TML differently between 5.2 and 5.3 (assuming
your application uses Tapestry's built-in TextField component), but some
JavaScript changes could break your client side code. Please note when you
are examining HTML content in the browser using common tools, you see the
current DOM state potentially modified by any JavaScripts executed. See
first what the server actually returns, and if it is OK, try checking your
JavaScripts for any incompatibilities.

Best regards,
Cezary




On Wed, Nov 2, 2016 at 2:08 PM, Lherm Nicolas  wrote:

> Hello,
>
> Yes, sorry I've made a mistake in the example (here is the real one) :
>
> 
>
>
> When I deploy my application in Tapestry 5.2.6 I have this code in the
> browser (source code) :
>
>  class="typeFacture" onchange="onTypeFactureChanged();" size="30"
> id="typeFacture" name="typeFacture" type="text">
>
> And this is the same code but with Tapestry 5.3.8 (nothing change in the
> tml…) :
>
> 
>
> Thanks
>
> -Message d'origine-
> De : Thiago H. de Paula Figueiredo [mailto:thiag...@gmail.com]
> Envoyé : mercredi 2 novembre 2016 14:04
> À : Tapestry users 
> Objet : Re: Javascript function not present in html source
>
> Hi!
>
> Are you sure you're looking at the same field? The id in the 5.3.8 example
> doesn't match the one in the 5.2.6 one.
>
> Cheers!
>
> On Wed, Nov 2, 2016 at 6:52 AM, Lherm Nicolas  wrote:
>
> > Hi,
> >
> > When I switched the version of Tapestry from 5.2.6 to 5.3.8 I saw
> > somes changes in the source code of the html page.
> >
> > In my tml file in eclipse I've this code :
> >
> >  > t:validate="required" class="typeFacture" onchange="
> onTypeFactureChanged();"
> > onblur="hideTfDropDown();" size="30" maxlength="30"
> > t:clientEvent="custom:change" t:event="typeFactureChanged"/>
> >
> > When I deploy my application in Tapestry 5.2.6 I have this code in the
> > browser (source code) :
> >
> >  > class="typeFacture" onchange="onTypeFactureChanged();" size="30"
> > id="typeFacture" name="typeFacture" type="text">
> >
> > And this is the same code but with Tapestry 5.3.8 (nothing change in
> > the
> > tml...) :
> >
> >  > type="text">
> >
> > So, somes portions of the code have disappeared (all of the javascript
> > functions..) but I don't know why ?
> >
> > I didn't find any reference to this problem in the release of the 5.3.
> >
> > Thanks,
> >
> >
>
>
> --
> Thiago
>


RE: Javascript function not present in html source

2016-11-02 Thread Lherm Nicolas


Re: Javascript function not present in html source

2016-11-02 Thread Thiago H. de Paula Figueiredo
Hi!

Are you sure you're looking at the same field? The id in the 5.3.8 example
doesn't match the one in the 5.2.6 one.

Cheers!

On Wed, Nov 2, 2016 at 6:52 AM, Lherm Nicolas  wrote:

> Hi,
>
> When I switched the version of Tapestry from 5.2.6 to 5.3.8 I saw somes
> changes in the source code of the html page.
>
> In my tml file in eclipse I've this code :
>
>  t:validate="required" class="typeFacture" onchange="onTypeFactureChanged();"
> onblur="hideTfDropDown();" size="30" maxlength="30"
> t:clientEvent="custom:change" t:event="typeFactureChanged"/>
>
> When I deploy my application in Tapestry 5.2.6 I have this code in the
> browser (source code) :
>
>  class="typeFacture" onchange="onTypeFactureChanged();" size="30"
> id="typeFacture" name="typeFacture" type="text">
>
> And this is the same code but with Tapestry 5.3.8 (nothing change in the
> tml...) :
>
>  type="text">
>
> So, somes portions of the code have disappeared (all of the javascript
> functions..) but I don't know why ?
>
> I didn't find any reference to this problem in the release of the 5.3.
>
> Thanks,
>
>


-- 
Thiago


Javascript function not present in html source

2016-11-02 Thread Lherm Nicolas
Hi,

When I switched the version of Tapestry from 5.2.6 to 5.3.8 I saw somes changes 
in the source code of the html page.

In my tml file in eclipse I've this code :



When I deploy my application in Tapestry 5.2.6 I have this code in the browser 
(source code) :



And this is the same code but with Tapestry 5.3.8 (nothing change in the 
tml...) :



So, somes portions of the code have disappeared (all of the javascript 
functions..) but I don't know why ?

I didn't find any reference to this problem in the release of the 5.3.

Thanks,



Re: Javascript black fade window on everypage unil js loaded.

2016-08-29 Thread Pavel Chernyak
Thank you, exactly what i need.

On 29 August 2016 at 13:14, Carlos Montero Canabal <
carlosmonterocana...@gmail.com> wrote:

> You can disable loading mask into your AppModule with the symbol
>
> /**
>  * If true, then when a page includes any JavaScript, a {@code script}
> block is added to insert
>  * a pageloader mask into the page; the pageloader mask ensure that
> the user can't interact with the page
>  * until after the page is fully initialized.
>  *
>  * @since 5.4
>  */
> public static final String ENABLE_PAGELOADING_MASK =
> "tapestry.enable-pageloading-mask”;
>
>
>
>
> El 29/8/2016, a las 12:12, Pavel Chernyak  escribió:
>
> Or maybe disable it?
>
>
>


Re: Javascript black fade window on everypage unil js loaded.

2016-08-29 Thread Carlos Montero Canabal
You can disable loading mask into your AppModule with the symbol 

/**
 * If true, then when a page includes any JavaScript, a {@code script} 
block is added to insert
 * a pageloader mask into the page; the pageloader mask ensure that the 
user can't interact with the page
 * until after the page is fully initialized.
 *
 * @since 5.4
 */
public static final String ENABLE_PAGELOADING_MASK = 
"tapestry.enable-pageloading-mask”;




> El 29/8/2016, a las 12:12, Pavel Chernyak  escribió:
> 
> Or maybe disable it?



smime.p7s
Description: S/MIME cryptographic signature


Javascript black fade window on everypage unil js loaded.

2016-08-29 Thread Pavel Chernyak
Greetings. I think everyone already noticed when page is opened on t5.4 -
there some time till all js libralies loaded.

Is there any options, how to optimize and speed it up?
Or maybe disable it?

-- 
With best regards,
Pavel Chernyak


Re: Hiding FormFragment via javascript

2016-03-29 Thread JumpStart
I can’t remember all the problems I had when combining FormFragment with Loop 
with modals, but I do know that I solved them all by moving the FormFragment to 
above the loop, adding an If, putting the modal inside it and, on submit of the 
modal, the server-side updated the relevant loop item’s values. This allowed it 
to handle create, update, and delete of loop items.

Admittedly this is with T5.4, but I don’t expect that to make much difference.

For example, here’s a snippet. It’s from a component that I’ll call 
ThingsEditor.




















...

...

...


${message:add-label}



Does that help?

Geoff

> On 24 Mar 2016, at 7:25 PM, Hendrik Grewe  wrote:
> 
> Hi Dimitris!
> 
> we are currently running Tapestry 5.3.8.
> An Upgrade to T5.4 is currently not feasible.
> 
> Hendrik
> 
> Am 24.03.2016 um 00:17 schrieb Dimitris Zenios:
>> hendrk what version of tapestry are you using?
>> On 23 Mar 2016 16:00, "Hendrik Grewe"  wrote:
>> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 



Re: Hiding FormFragment via javascript

2016-03-29 Thread Hendrik Grewe
Hi Dimitris!

we are currently running Tapestry 5.3.8.
An Upgrade to T5.4 is currently not feasible.

Hendrik

Am 24.03.2016 um 00:17 schrieb Dimitris Zenios:
> hendrk what version of tapestry are you using?
> On 23 Mar 2016 16:00, "Hendrik Grewe"  wrote:
> 

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



Re: Hiding FormFragment via javascript

2016-03-23 Thread Dimitris Zenios
hendrk what version of tapestry are you using?
On 23 Mar 2016 16:00, "Hendrik Grewe"  wrote:

> Hi @ list!
>
> I have a loop within a Form containing a formfragment per row.
> The FormFragment is displayed within a (bootstrap) modal dialog, which
> is opened by a click of a button in the current Row of the loop.
> Fields within those formfragments are required.
> The problem arises if one opens the modal-dialog containing the
> FormFragment, then closing the dialog again without entering data.
> Now if one tries to submit the form the (hidden!) Fields within the
> modal dialog are flagged as errornous because they are not filled in.
>
> Why is the formfragment seen as "visible" and thus it is tried to submit
> when the containing div is NOT visible?
>
> Is there a way to force the visibility status of a formfragment (via
> clientSide javascript?)
>
> Is there any further documentation about when a formFragment is seen as
> visible/hidden?
>
> I played a little with visibleBound on the formfragment  like:
>
>  id="myModal_specialId"
> tabindex="-1" role="dialog"
> aria-labelledby="myModalLabelEdit">
>
>  visibleBound='jQuery("#myModal_specialId").is(":visible")'>
>
> 
> 
>
> Which also did not help any further.
>
> Any help is greatly appreciated
>
>
>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Hiding FormFragment via javascript

2016-03-23 Thread Hendrik Grewe
Hi @ list!

I have a loop within a Form containing a formfragment per row.
The FormFragment is displayed within a (bootstrap) modal dialog, which
is opened by a click of a button in the current Row of the loop.
Fields within those formfragments are required.
The problem arises if one opens the modal-dialog containing the
FormFragment, then closing the dialog again without entering data.
Now if one tries to submit the form the (hidden!) Fields within the
modal dialog are flagged as errornous because they are not filled in.

Why is the formfragment seen as "visible" and thus it is tried to submit
when the containing div is NOT visible?

Is there a way to force the visibility status of a formfragment (via
clientSide javascript?)

Is there any further documentation about when a formFragment is seen as
visible/hidden?

I played a little with visibleBound on the formfragment  like:








Which also did not help any further.

Any help is greatly appreciated





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



Re: [5.4] request from javascript to Tapestry event

2016-02-15 Thread Nathan Quirynen

Thanks for the link.
I think I fixed it adding just the following in my request callback 
function:


pageinit.handlePartialPageRenderResponse({ json : r });

On 05/02/16 15:04, Chris Poulsen wrote:

Have a look at http://tapestry.apache.org/current/coffeescript/ajax.html




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



Re: [5.4] request from javascript to Tapestry event

2016-02-05 Thread Chris Poulsen
Faking a "click" on an invisible async eventlink could also be a very
simple way to get this working without having to mock around with much
javascript.

-- 
Chris

On Fri, Feb 5, 2016 at 3:04 PM, Chris Poulsen 
wrote:

> Have a look at http://tapestry.apache.org/current/coffeescript/ajax.html
>
> --
> Chris
>
> On Fri, Feb 5, 2016 at 2:54 PM, Nathan Quirynen <
> nat...@pensionarchitects.be> wrote:
>
>> Hi,
>>
>> I have finally started the process of updating to 5.4.
>> Some components have an initializer javascript where an eventlink url is
>> passed as a parameter to be used as the url for a request from javascript
>> to a Tapestry event.
>> To handle the response (zone updates, scripts, ..) I added in the request
>> callback function the following:
>>
>> $.get(spec.eventLink, function(r) {
>>
>> if (r.zones) {
>> $.each(r.zones, function(zoneId){
>> $('#' + zoneId).tapestryZone("applyContentUpdate",
>> r.zones[zoneId]);
>> });
>> }
>>
>> if (r.updateZone) {
>> var spec = {
>> url: r.updateZone.url,
>> params: r.updateZone.params
>> };
>> $('#' + r.updateZone.zoneId).tapestryZone("update", spec);
>> }
>> $.tapestry.utils.loadScriptsInReply(r);
>>
>> });
>>
>> I thought this was not the best solution, but did not find another one at
>> the moment and it worked.
>> Now in 5.4 it does not work anymore, so how do I have to fire requests to
>> tapestry events from javascript and make it handle the response?
>>
>> Nathan
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>>
>


Re: [5.4] request from javascript to Tapestry event

2016-02-05 Thread Chris Poulsen
Have a look at http://tapestry.apache.org/current/coffeescript/ajax.html

-- 
Chris

On Fri, Feb 5, 2016 at 2:54 PM, Nathan Quirynen  wrote:

> Hi,
>
> I have finally started the process of updating to 5.4.
> Some components have an initializer javascript where an eventlink url is
> passed as a parameter to be used as the url for a request from javascript
> to a Tapestry event.
> To handle the response (zone updates, scripts, ..) I added in the request
> callback function the following:
>
> $.get(spec.eventLink, function(r) {
>
> if (r.zones) {
> $.each(r.zones, function(zoneId){
> $('#' + zoneId).tapestryZone("applyContentUpdate",
> r.zones[zoneId]);
> });
> }
>
> if (r.updateZone) {
> var spec = {
> url: r.updateZone.url,
> params: r.updateZone.params
> };
> $('#' + r.updateZone.zoneId).tapestryZone("update", spec);
> }
> $.tapestry.utils.loadScriptsInReply(r);
>
> });
>
> I thought this was not the best solution, but did not find another one at
> the moment and it worked.
> Now in 5.4 it does not work anymore, so how do I have to fire requests to
> tapestry events from javascript and make it handle the response?
>
> Nathan
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


[5.4] request from javascript to Tapestry event

2016-02-05 Thread Nathan Quirynen

Hi,

I have finally started the process of updating to 5.4.
Some components have an initializer javascript where an eventlink url is 
passed as a parameter to be used as the url for a request from 
javascript to a Tapestry event.
To handle the response (zone updates, scripts, ..) I added in the 
request callback function the following:


$.get(spec.eventLink, function(r) {

if (r.zones) {
$.each(r.zones, function(zoneId){
$('#' + zoneId).tapestryZone("applyContentUpdate", 
r.zones[zoneId]);

});
}

if (r.updateZone) {
var spec = {
url: r.updateZone.url,
params: r.updateZone.params
};
$('#' + r.updateZone.zoneId).tapestryZone("update", spec);
}
$.tapestry.utils.loadScriptsInReply(r);

});

I thought this was not the best solution, but did not find another one 
at the moment and it worked.
Now in 5.4 it does not work anymore, so how do I have to fire requests 
to tapestry events from javascript and make it handle the response?


Nathan

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



Re: send data from javascript to tapestry.

2015-12-15 Thread Thiago H de Paula Figueiredo

On Tue, 15 Dec 2015 08:57:54 -0200,  wrote:


Hi,


Hi!

I have one question, how can i send parameter from javascript to  
tapestry?

I read about ComponentResources but i dont have idea how does it work.
I use Tapestry ver. 5.3.5.


See  
http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/Calling-the-Tapestry-server-from-plain-Javascript-td3298149.html  
and  
http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/Call-event-from-javascript-td5096654.html


--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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



send data from javascript to tapestry.

2015-12-15 Thread wtf117
Hi,

I have one question, how can i send parameter from javascript to tapestry?
I read about ComponentResources but i dont have idea how does it work.
I use Tapestry ver. 5.3.5.


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



Re: javascript error

2015-10-09 Thread Christine

On 08-10-15 15:49, Christine wrote:


The page has a submit button, that doesn't seem to do anything.


The problem seems to be in regexp. This works:


but this doesn't:



(I do have the regexp definition in a properties file).

When I put

I get an error message for the input, always.


dagdag
Christine





This is the error I get,

Form validiation/submit error `TypeError: input.match is not a 
function', in form ElementWrapper[action="/gossipUI/admin/addserver.addserverform" method="post" 
id="addServerForm" class="has-error">], triggering 
t5:field:input-validation event on ElementWrapper[data-regexp-message="Port does not match pattern '^[0-9]+$'." 
data-validate-regexp="^[0-9]+$" data-max-length-message="You may 
provide at most 5 characters for Port." data-validate-max-length="5" 
data-required-message="You must provide a value for Port." 
data-optionality="required" data-translation-message="You must provide 
an integer value for Port." data-translation="integer" 
data-validation="true" value="0" id="port" class="form-control" 
name="port" type="text">]


together with this one

TypeError: input.match is not a function(…)
  defaultValidateAndSubmit @ core.js:443
  wrapped @ core.js:413
  jQuery.event.dispatch @ core.js:230
  jQuery.event.add.elemData.handle @ core.js:220


a jar "js.jar" is on my classpath, do I need to have that?

dagdag
Christine

-
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: javascript error

2015-10-08 Thread Christine


I forgot that I recently added a line in my module file
configuration.add(SymbolConstants.JAVASCRIPT_INFRASTRUCTURE_PROVIDER, 
"jquery");


as suggested on my previous question on this list. My good friend 
Martijn reminded me of this :-)


Removing the line solves the current issue. So now I'm looking for a fix 
that allows me to run Ajax properly and have the submit button work.


dagdag
Christine


On 08-10-15 15:49, Christine wrote:

Hi,

I have a form in a page that worked fine until recently. It stopped 
working after I reinstalled Ubuntu and after I switched from Tapestry 
beta26 to beta35. I am not aware of changes in my code.


The page has a submit button, that doesn't seem to do anything.

This is the error I get,

Form validiation/submit error `TypeError: input.match is not a 
function', in form ElementWrapper[action="/gossipUI/admin/addserver.addserverform" method="post" 
id="addServerForm" class="has-error">], triggering 
t5:field:input-validation event on ElementWrapper[data-regexp-message="Port does not match pattern '^[0-9]+$'." 
data-validate-regexp="^[0-9]+$" data-max-length-message="You may 
provide at most 5 characters for Port." data-validate-max-length="5" 
data-required-message="You must provide a value for Port." 
data-optionality="required" data-translation-message="You must provide 
an integer value for Port." data-translation="integer" 
data-validation="true" value="0" id="port" class="form-control" 
name="port" type="text">]


together with this one

TypeError: input.match is not a function(…)
  defaultValidateAndSubmit @ core.js:443
  wrapped @ core.js:413
  jQuery.event.dispatch @ core.js:230
  jQuery.event.add.elemData.handle @ core.js:220


a jar "js.jar" is on my classpath, do I need to have that?

dagdag
Christine

-
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



javascript error

2015-10-08 Thread Christine

Hi,

I have a form in a page that worked fine until recently. It stopped 
working after I reinstalled Ubuntu and after I switched from Tapestry 
beta26 to beta35. I am not aware of changes in my code.


The page has a submit button, that doesn't seem to do anything.

This is the error I get,

Form validiation/submit error `TypeError: input.match is not a 
function', in form ElementWrapper[action="/gossipUI/admin/addserver.addserverform" method="post" 
id="addServerForm" class="has-error">], triggering 
t5:field:input-validation event on ElementWrapper[data-regexp-message="Port does not match pattern '^[0-9]+$'." 
data-validate-regexp="^[0-9]+$" data-max-length-message="You may provide 
at most 5 characters for Port." data-validate-max-length="5" 
data-required-message="You must provide a value for Port." 
data-optionality="required" data-translation-message="You must provide 
an integer value for Port." data-translation="integer" 
data-validation="true" value="0" id="port" class="form-control" 
name="port" type="text">]


together with this one

TypeError: input.match is not a function(…)
  defaultValidateAndSubmit @ core.js:443
  wrapped @ core.js:413
  jQuery.event.dispatch @ core.js:230
  jQuery.event.add.elemData.handle @ core.js:220


a jar "js.jar" is on my classpath, do I need to have that?

dagdag
Christine

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



Re: How do I unit test Javascript in Tapestry applications?

2015-08-19 Thread Lance Java
A word of warning... Selenium tests can be very problematic and I'm sitting
on the fence as to whether they are actually worth the maintenance cost.

That being said, the tapestry build itself has comprehensive Selenium
tests. Have a look through the source code for examples.
On 17 Aug 2015 12:55, "Poggenpohl, Daniel" <
daniel.poggenp...@isst.fraunhofer.de> wrote:

> Hello,
>
> We're trying to test our Tapestry application. We know that we can test
> our pages with
> https://tapestry.apache.org/unit-testing-pages-or-components.html
>
> But how do we test the JavaScript we implemented? It would seem that we
> would need a Tapestry generated html page and then call the scripts somehow.
>
> How do you implement JavaScript testing?
>
> Regards,
> Daniel P.
>


How do I unit test Javascript in Tapestry applications?

2015-08-17 Thread Poggenpohl, Daniel
Hello,

We're trying to test our Tapestry application. We know that we can test our 
pages with
https://tapestry.apache.org/unit-testing-pages-or-components.html

But how do we test the JavaScript we implemented? It would seem that we would 
need a Tapestry generated html page and then call the scripts somehow.

How do you implement JavaScript testing?

Regards,
Daniel P.


Re: JavaScriptSupport dynamic javascript

2015-02-27 Thread Thiago H de Paula Figueiredo
On Thu, 26 Feb 2015 19:18:58 -0300, David Cline  
 wrote:



Hey all,


Hi!


Using Tapestry 5.4.28 is there a way to inject dynamically generated
javascript into JavaScriptSupport.Require() instead of an external
javascript file?


No. You can use the deprecated JavaScriptSupport.addScript() method for  
that. What exactly are you trying to do?


--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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



JavaScriptSupport dynamic javascript

2015-02-26 Thread David Cline
Hey all,

 

Using Tapestry 5.4.28 is there a way to inject dynamically generated
javascript into JavaScriptSupport.Require() instead of an external
javascript file?

 

**Example**

 

@Environmental

private JavaScriptSupport jss;

 

void afterRender() {

jss.require(**dynamically generated javascript**);

}

 

I stumbled across this topic in the archives which shows an example of an
external javascript file being injected.

 

http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/How-to-us
e-new-JavaScriptSupport-require-in-5-4-td5722177.html

 

Thanks



Re: Tapestry 5.4 JavaScript support .... support request

2015-02-24 Thread Lance Java
You might be interested in the griddecorator mixin from tapestry-stitch

See the example here which adds a context sensitive alert to the "onclick"
of every row

https://t5stitch-lazan.rhcloud.com/griddecoratordemo
On 23 Feb 2015 18:39, "Poggenpohl, Daniel" <
daniel.poggenp...@isst.fraunhofer.de> wrote:

> Hello everyone,
>
> I'm trying to add some functionality to a grid:
>
> Every grid row should be an area where you can click to go to the details
> page of the row object.
>
> But enough of that, even a simple javascript like alert on click doesn't
> seem to work.
>
> The js is added via jss.addScript(), which is deprecated in 5.4 . Doing it
> this way doesn't seem to work. What happens is I apply the script via a
> @MixinAfter mixin in an afterRender-method and the page containing the grid
> displays the loading spinnerfor eternity.
>
> The javadoc says I should use modules and RequireJS. Is there an existing
> example how to do this?
>
> The project uses jquery as the provider.
>
> Regards,
> Daniel Poggenpohl
>


AW: Tapestry 5.4 JavaScript support .... support request

2015-02-24 Thread Poggenpohl, Daniel
Hi,

that's what I get for always looking at the page-specific code only. Thank you.

Regards,
Daniel P.

-Ursprüngliche Nachricht-
Von: Geoff Callender [mailto:geoff.callender.jumpst...@gmail.com] 
Gesendet: Dienstag, 24. Februar 2015 02:41
An: Tapestry users
Betreff: Re: Tapestry 5.4 JavaScript support  support request

On 24 Feb 2015, at 9:59 am, Poggenpohl, Daniel 
 wrote:

> Hello,
> 
> the Jumpstart tutorial says "They reside in resources/META-INF/modules."
> 
> Is it src/main/resources/META-INF/modules ?
> 
If you go to any of the examples and search for "sourcecodetab" you'll see the 
answer.

> Regards,
> Daniel P.
> 
> Von: Geoff Callender [geoff.callender.jumpst...@gmail.com]
> Gesendet: Montag, 23. Februar 2015 22:13
> An: Tapestry users
> Betreff: Re: Tapestry 5.4 JavaScript support  support request
> 
> On 24 Feb 2015, at 5:38 am, Poggenpohl, Daniel 
>  wrote:
> 
>> Hello everyone,
>> 
>> I'm trying to add some functionality to a grid:
>> 
>> Every grid row should be an area where you can click to go to the details 
>> page of the row object.
>> 
>> But enough of that, even a simple javascript like alert on click doesn't 
>> seem to work.
>> 
>> The js is added via jss.addScript(), which is deprecated in 5.4 . Doing it 
>> this way doesn't seem to work. What happens is I apply the script via a 
>> @MixinAfter mixin in an afterRender-method and the page containing the grid 
>> displays the loading spinnerfor eternity.
>> 
>> The javadoc says I should use modules and RequireJS. Is there an existing 
>> example how to do this?
> 
> Some examples:
> 
>
> http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/javascript
>
> http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/reusable
>
> http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/robust
>
> http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/mixin
> 
> HTH,
> 
> Geoff
> 
>> 
>> The project uses jquery as the provider.
>> 
>> Regards,
>> Daniel Poggenpohl
> 
> 
> -
> 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


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



Re: Tapestry 5.4 JavaScript support .... support request

2015-02-23 Thread Geoff Callender
On 24 Feb 2015, at 9:59 am, Poggenpohl, Daniel 
 wrote:

> Hello,
> 
> the Jumpstart tutorial says "They reside in resources/META-INF/modules."
> 
> Is it src/main/resources/META-INF/modules ?
> 
If you go to any of the examples and search for "sourcecodetab" you'll see the 
answer.

> Regards,
> Daniel P.
> 
> Von: Geoff Callender [geoff.callender.jumpst...@gmail.com]
> Gesendet: Montag, 23. Februar 2015 22:13
> An: Tapestry users
> Betreff: Re: Tapestry 5.4 JavaScript support  support request
> 
> On 24 Feb 2015, at 5:38 am, Poggenpohl, Daniel 
>  wrote:
> 
>> Hello everyone,
>> 
>> I'm trying to add some functionality to a grid:
>> 
>> Every grid row should be an area where you can click to go to the details 
>> page of the row object.
>> 
>> But enough of that, even a simple javascript like alert on click doesn't 
>> seem to work.
>> 
>> The js is added via jss.addScript(), which is deprecated in 5.4 . Doing it 
>> this way doesn't seem to work. What happens is I apply the script via a 
>> @MixinAfter mixin in an afterRender-method and the page containing the grid 
>> displays the loading spinnerfor eternity.
>> 
>> The javadoc says I should use modules and RequireJS. Is there an existing 
>> example how to do this?
> 
> Some examples:
> 
>
> http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/javascript
>
> http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/reusable
>
> http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/robust
>
> http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/mixin
> 
> HTH,
> 
> Geoff
> 
>> 
>> The project uses jquery as the provider.
>> 
>> Regards,
>> Daniel Poggenpohl
> 
> 
> -
> 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



AW: Tapestry 5.4 JavaScript support .... support request

2015-02-23 Thread Poggenpohl, Daniel
Hello,

the Jumpstart tutorial says "They reside in resources/META-INF/modules."

Is it src/main/resources/META-INF/modules ?

Regards,
Daniel P.

Von: Geoff Callender [geoff.callender.jumpst...@gmail.com]
Gesendet: Montag, 23. Februar 2015 22:13
An: Tapestry users
Betreff: Re: Tapestry 5.4 JavaScript support  support request

On 24 Feb 2015, at 5:38 am, Poggenpohl, Daniel 
 wrote:

> Hello everyone,
>
> I'm trying to add some functionality to a grid:
>
> Every grid row should be an area where you can click to go to the details 
> page of the row object.
>
> But enough of that, even a simple javascript like alert on click doesn't seem 
> to work.
>
> The js is added via jss.addScript(), which is deprecated in 5.4 . Doing it 
> this way doesn't seem to work. What happens is I apply the script via a 
> @MixinAfter mixin in an afterRender-method and the page containing the grid 
> displays the loading spinnerfor eternity.
>
> The javadoc says I should use modules and RequireJS. Is there an existing 
> example how to do this?

Some examples:

    
http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/javascript
    
http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/reusable
    
http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/robust
    
http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/mixin

HTH,

Geoff

>
> The project uses jquery as the provider.
>
> Regards,
> Daniel Poggenpohl


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



Re: Tapestry 5.4 JavaScript support .... support request

2015-02-23 Thread Geoff Callender

On 24 Feb 2015, at 5:38 am, Poggenpohl, Daniel 
 wrote:

> Hello everyone,
> 
> I'm trying to add some functionality to a grid:
> 
> Every grid row should be an area where you can click to go to the details 
> page of the row object.
> 
> But enough of that, even a simple javascript like alert on click doesn't seem 
> to work.
> 
> The js is added via jss.addScript(), which is deprecated in 5.4 . Doing it 
> this way doesn't seem to work. What happens is I apply the script via a 
> @MixinAfter mixin in an afterRender-method and the page containing the grid 
> displays the loading spinnerfor eternity.
> 
> The javadoc says I should use modules and RequireJS. Is there an existing 
> example how to do this?

Some examples:

    
http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/javascript
    
http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/reusable
    
http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/robust
    
http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/mixin

HTH,

Geoff

> 
> The project uses jquery as the provider.
> 
> Regards,
> Daniel Poggenpohl



Re: Tapestry 5.4 JavaScript support .... support request

2015-02-23 Thread Thiago H de Paula Figueiredo
On Mon, 23 Feb 2015 15:38:30 -0300, Poggenpohl, Daniel  
 wrote:



Hello everyone,

I'm trying to add some functionality to a grid:

Every grid row should be an area where you can click to go to the  
details page of the row object.


But enough of that, even a simple javascript like alert on click doesn't  
seem to work.


The js is added via jss.addScript(), which is deprecated in 5.4 . Doing  
it this way doesn't seem to work. What happens is I apply the script via  
a @MixinAfter mixin in an afterRender-method and the page containing the  
grid displays the loading spinnerfor eternity.


This very probably means you have an JavaScript error. Have you checker  
the error console from Firebug or Chrome equivalent?


The javadoc says I should use modules and RequireJS. Is there an  
existing example how to do this?


This mailing list archives have a handful.



The project uses jquery as the provider.

Regards,
Daniel Poggenpohl



--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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



AW: Tapestry 5.4 JavaScript support .... support request

2015-02-23 Thread Poggenpohl, Daniel
Hi,

I've basically copied the code from
http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/Render-whole-table-grid-row-as-a-link-tp5717388p5717399.html

@MixinAfter
public class RowEvent {
@InjectContainer
private Grid grid;
   
@Inject
private JavaScriptSupport jss;
   
@Inject
private ComponentResources componentResrouces;
   
@Parameter(required=true)
private String event;
   
public void afterRender(MarkupWriter writer) {
GridDataSource dataSource = grid.getDataSource();
Element tbody = writer.getElement().find("table/tbody");
List children = tbody.getChildren();
for (int i = 0; i < children.size(); ++i) {
Element tr = (Element) children.get(i);
String rowId = jss.allocateClientId("row");
   
// give each row an id
tr.attribute("id", rowId);
   
// this will be passed as a parameter to the serverside 
event
Object rowContext = dataSource.getRowValue(i);
   
// this event will bubble up to the containing page / 
component
Link eventLink = 
componentResrouces.createEventLink(event, rowContext);
   
// observe the 'click' event and fire the eventlink
jss.addScript("Event.observe('%s', 'click', function() 
{ window.location.href = '%s' })", rowId, eventLink);
}
}
}

I understand that the jss.addScript line uses Prototype functions, while our 
project uses jquery.
I changed the line to

jss.addScript("$(#'%s').click(alert('BOO!'))", rowId);

I want the above to say "The element with the id rowId gets a click event. When 
the row is clicked, an alertbox should appear, containing nonsense text. Just 
for debugging.

But that didn't work, either.

Regards,
Daniel P.

Von: George Christman [gchrist...@cardaddy.com]
Gesendet: Montag, 23. Februar 2015 20:46
An: Tapestry users
Betreff: Re: Tapestry 5.4 JavaScript support  support request

On Mon, Feb 23, 2015 at 1:38 PM, Poggenpohl, Daniel <
daniel.poggenp...@isst.fraunhofer.de> wrote:

> Hello everyone,
>
> I'm trying to add some functionality to a grid:
>
> Every grid row should be an area where you can click to go to the details
> page of the row object.
>
> But enough of that, even a simple javascript like alert on click doesn't
> seem to work.
>
> The js is added via jss.addScript(), which is deprecated in 5.4 . Doing it
> this way doesn't seem to work. What happens is I apply the script via a
> @MixinAfter mixin in an afterRender-method and the page containing the grid
> displays the loading spinnerfor eternity.
>

You should post some code for us to see.

>
> The javadoc says I should use modules and RequireJS. Is there an existing
> example how to do this?
>

You can take a look at the Autocomplete mixin for an example on how to use
requirejs with tapestry.

Mixin
https://github.com/apache/tapestry-5/blob/5.4-beta-28/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/Autocomplete.java

JS
https://github.com/apache/tapestry-5/blob/5.4-beta-28/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/autocomplete.coffee

btw, tapestry is using coffeescript in their js, so if your unfamiliar with
it, it can make things look a bit more confusing.


> The project uses jquery as the provider.
>
> Regards,
> Daniel Poggenpohl
>

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



Re: Tapestry 5.4 JavaScript support .... support request

2015-02-23 Thread George Christman
On Mon, Feb 23, 2015 at 1:38 PM, Poggenpohl, Daniel <
daniel.poggenp...@isst.fraunhofer.de> wrote:

> Hello everyone,
>
> I'm trying to add some functionality to a grid:
>
> Every grid row should be an area where you can click to go to the details
> page of the row object.
>
> But enough of that, even a simple javascript like alert on click doesn't
> seem to work.
>
> The js is added via jss.addScript(), which is deprecated in 5.4 . Doing it
> this way doesn't seem to work. What happens is I apply the script via a
> @MixinAfter mixin in an afterRender-method and the page containing the grid
> displays the loading spinnerfor eternity.
>

You should post some code for us to see.

>
> The javadoc says I should use modules and RequireJS. Is there an existing
> example how to do this?
>

You can take a look at the Autocomplete mixin for an example on how to use
requirejs with tapestry.

Mixin
https://github.com/apache/tapestry-5/blob/5.4-beta-28/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/Autocomplete.java

JS
https://github.com/apache/tapestry-5/blob/5.4-beta-28/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/autocomplete.coffee

btw, tapestry is using coffeescript in their js, so if your unfamiliar with
it, it can make things look a bit more confusing.


> The project uses jquery as the provider.
>
> Regards,
> Daniel Poggenpohl
>


AW: Tapestry 5.4 JavaScript support .... support request

2015-02-23 Thread Poggenpohl, Daniel
Hello everyone,

oh, I forgot, I use Tapestry 5.4 Beta 22.

Regards,
Daniel P.

Hello everyone,

I'm trying to add some functionality to a grid:

Every grid row should be an area where you can click to go to the details page 
of the row object.

But enough of that, even a simple javascript like alert on click doesn't seem 
to work.

The js is added via jss.addScript(), which is deprecated in 5.4 . Doing it this 
way doesn't seem to work. What happens is I apply the script via a @MixinAfter 
mixin in an afterRender-method and the page containing the grid displays the 
loading spinnerfor eternity.

The javadoc says I should use modules and RequireJS. Is there an existing 
example how to do this?

The project uses jquery as the provider.

Regards,
Daniel Poggenpohl

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



Tapestry 5.4 JavaScript support .... support request

2015-02-23 Thread Poggenpohl, Daniel
Hello everyone,

I'm trying to add some functionality to a grid:

Every grid row should be an area where you can click to go to the details page 
of the row object.

But enough of that, even a simple javascript like alert on click doesn't seem 
to work.

The js is added via jss.addScript(), which is deprecated in 5.4 . Doing it this 
way doesn't seem to work. What happens is I apply the script via a @MixinAfter 
mixin in an afterRender-method and the page containing the grid displays the 
loading spinnerfor eternity.

The javadoc says I should use modules and RequireJS. Is there an existing 
example how to do this?

The project uses jquery as the provider.

Regards,
Daniel Poggenpohl


Re: Trying to load non AMD javascript in tapestry 5.4

2015-02-19 Thread abangkis
Hi Diego and Geoff thanks a lot for the examples. Will work on it again
next week.

On Wed, Feb 18, 2015 at 11:01 PM, Diego Socaceti  wrote:

> Hi Geoff,
>
> here the missing parts :)
>
> The JavaScriptLibraryModule now have configured four new modules based on
> non-AMD JavaScript:
> ["modernizr", "class", "font-picker", "date-format"].
>
> - "modernizr" js stores itself in a browser global called "Modernizr"
> ==> .exports("Modernizr")
> - "class" js stores itself in a browser global called "Class"
> ==> .exports("Class")
> - "font-picker" is a jquery plugin
> ==> .dependsOn("jquery")
> - "date-format" is a jquery pluhin, which stores itself in a browser global
> called 'DateFormat'
> ==> .exports("DateFormat").dependsOn("jquery")
>
>
>
> define([ 'modernizr' ], function(myModernizr) {
>   var sampleSvgMethod = function() {
> if (!myModernizr.svg) {
> ...
> }
>   };
>
>   return {
> sampleSvgMethod: sampleSvgMethod,
>   };
> });
>
> define(["jquery", 'font-picker'], function($) {
>   return function (clientIdOfInputField) {
> $('#' + clientIdOfInputField).fontSelector({
>   'hide_fallbacks' : true,
>   'selected' : function(style) { $("#fontTypeField").val(style); },
>   'fonts' : [
> 'Arial,Arial,Helvetica,sans-serif',
> 'Arial Black,Arial Black,Gadget,sans-serif',
> ...
> ]
> });
>   }});
>
>
> Kind regards
>
>
> 2015-02-18 16:24 GMT+01:00 Diego Socaceti :
>
> > Hi Geoff,
> >
> > yes, here is some productive code:
> >
> > public class JavaScriptLibraryModule {
> >
> >   private static final String MODERNIZR_PATH =
> > "context:third-party/modernizr-2.7.1.js";
> >   private static final String JS_SIMPLE_CLASS_PATH =
> > "context:third-party/class.js";
> >   private static final String JS_FONT_PICKER_PATH =
> > "context:third-party/fontselector/src/jquery.fontselector.js";
> >   private static final String JS_DATE_FORMAT_PATH =
> > "context:third-party/dateFormat.js";
> >
> >   @Contribute(ModuleManager.class)
> >   public static void
> > addExternalNonAmdJavaScript(MappedConfiguration
> > configuration,
> >   @Path(MODERNIZR_PATH) Resource modernizr,
> >   @Path(JS_SIMPLE_CLASS_PATH) Resource simpleClass
> >   @Path(JS_FONT_PICKER_PATH) Resource fontPicker,
> >   @Path(JS_DATE_FORMAT_PATH) Resource dateFormat) {
> >
> > configuration.add("modernizr",
> > new JavaScriptModuleConfiguration(modernizr)
> > .exports("Modernizr"));
> >
> > configuration.add("class", new
> > JavaScriptModuleConfiguration(simpleClass)
> > .exports("Class"));
> >
> > configuration.add("font-picker", new
> > JavaScriptModuleConfiguration(fontPicker)
> > .dependsOn("jquery"));
> >
> > configuration.add("date-format", new
> > JavaScriptModuleConfiguration(dateFormat)
> > .exports("DateFormat")
> >   .dependsOn("jquery"));
> >
> >   }
> > }
> >
> > Kind regards
> >
> >
> > 2015-02-18 15:04 GMT+01:00 Geoff Callender <
> > geoff.callender.jumpst...@gmail.com>:
> >
> >> Hi Diego,
> >>
> >> That sounds good, but can you give a concrete example of some code, like
> >> I gave below. That would be great.
> >>
> >> Geoff
> >>
> >>
> >> On 19 Feb 2015, at 1:00 am, Diego Socaceti  wrote:
> >>
> >> > sorry, copy, paste-error
> >> >
> >> > ... use JavaScriptModuleConfiguration#exports() for 'exports' of shim
> >> config
> >> >
> >> > 2015-02-18 14:58 GMT+01:00 Diego Socaceti :
> >> >
> >> >> Hi @all,
> >> >>
> >> >> if you want to shim non-AMD JavaScript files you should use
> >> >> JavaScriptModuleConfiguration.
> >> >> It offers everything you need to create shim configs.
> >> >>
> >> >> use JavaScriptModuleConfiguration#dependsOn() for 'deps' of shim
> config
> >> >> use JavaScriptModuleConfiguration#dependsOn() for 'exports

Re: Trying to load non AMD javascript in tapestry 5.4

2015-02-18 Thread Diego Socaceti
Hi Geoff,

here the missing parts :)

The JavaScriptLibraryModule now have configured four new modules based on
non-AMD JavaScript:
["modernizr", "class", "font-picker", "date-format"].

- "modernizr" js stores itself in a browser global called "Modernizr"
==> .exports("Modernizr")
- "class" js stores itself in a browser global called "Class"
==> .exports("Class")
- "font-picker" is a jquery plugin
==> .dependsOn("jquery")
- "date-format" is a jquery pluhin, which stores itself in a browser global
called 'DateFormat'
==> .exports("DateFormat").dependsOn("jquery")



define([ 'modernizr' ], function(myModernizr) {
  var sampleSvgMethod = function() {
if (!myModernizr.svg) {
...
}
  };

  return {
sampleSvgMethod: sampleSvgMethod,
  };
});

define(["jquery", 'font-picker'], function($) {
  return function (clientIdOfInputField) {
$('#' + clientIdOfInputField).fontSelector({
  'hide_fallbacks' : true,
  'selected' : function(style) { $("#fontTypeField").val(style); },
  'fonts' : [
'Arial,Arial,Helvetica,sans-serif',
'Arial Black,Arial Black,Gadget,sans-serif',
...
]
});
  }});


Kind regards


2015-02-18 16:24 GMT+01:00 Diego Socaceti :

> Hi Geoff,
>
> yes, here is some productive code:
>
> public class JavaScriptLibraryModule {
>
>   private static final String MODERNIZR_PATH =
> "context:third-party/modernizr-2.7.1.js";
>   private static final String JS_SIMPLE_CLASS_PATH =
> "context:third-party/class.js";
>   private static final String JS_FONT_PICKER_PATH =
> "context:third-party/fontselector/src/jquery.fontselector.js";
>   private static final String JS_DATE_FORMAT_PATH =
> "context:third-party/dateFormat.js";
>
>   @Contribute(ModuleManager.class)
>   public static void
> addExternalNonAmdJavaScript(MappedConfiguration
> configuration,
>   @Path(MODERNIZR_PATH) Resource modernizr,
>   @Path(JS_SIMPLE_CLASS_PATH) Resource simpleClass
>   @Path(JS_FONT_PICKER_PATH) Resource fontPicker,
>   @Path(JS_DATE_FORMAT_PATH) Resource dateFormat) {
>
> configuration.add("modernizr",
> new JavaScriptModuleConfiguration(modernizr)
> .exports("Modernizr"));
>
> configuration.add("class", new
> JavaScriptModuleConfiguration(simpleClass)
> .exports("Class"));
>
> configuration.add("font-picker", new
> JavaScriptModuleConfiguration(fontPicker)
> .dependsOn("jquery"));
>
> configuration.add("date-format", new
> JavaScriptModuleConfiguration(dateFormat)
> .exports("DateFormat")
>   .dependsOn("jquery"));
>
>   }
> }
>
> Kind regards
>
>
> 2015-02-18 15:04 GMT+01:00 Geoff Callender <
> geoff.callender.jumpst...@gmail.com>:
>
>> Hi Diego,
>>
>> That sounds good, but can you give a concrete example of some code, like
>> I gave below. That would be great.
>>
>> Geoff
>>
>>
>> On 19 Feb 2015, at 1:00 am, Diego Socaceti  wrote:
>>
>> > sorry, copy, paste-error
>> >
>> > ... use JavaScriptModuleConfiguration#exports() for 'exports' of shim
>> config
>> >
>> > 2015-02-18 14:58 GMT+01:00 Diego Socaceti :
>> >
>> >> Hi @all,
>> >>
>> >> if you want to shim non-AMD JavaScript files you should use
>> >> JavaScriptModuleConfiguration.
>> >> It offers everything you need to create shim configs.
>> >>
>> >> use JavaScriptModuleConfiguration#dependsOn() for 'deps' of shim config
>> >> use JavaScriptModuleConfiguration#dependsOn() for 'exports' of shim
>> config
>> >>
>> >> Kind regards
>> >>
>> >>
>> >> 2015-02-18 12:13 GMT+01:00 Geoff Callender <
>> >> geoff.callender.jumpst...@gmail.com>:
>> >>
>> >>> Despite what I said 9 months ago in the thread you referenced, I'm not
>> >>> sure that I've ever seen the shimming [1] ever work, but I haven't
>> pursued
>> >>> it because the many javascript libraries I use work fine anyway
>> without
>> >>> being modules.
>> >>>
>> >>> [1]
>> >>>
>> http://tapestry.apache.org/5.4/apidocs/org/apache/

Re: Trying to load non AMD javascript in tapestry 5.4

2015-02-18 Thread Diego Socaceti
Hi Geoff,

yes, here is some productive code:

public class JavaScriptLibraryModule {

  private static final String MODERNIZR_PATH =
"context:third-party/modernizr-2.7.1.js";
  private static final String JS_SIMPLE_CLASS_PATH =
"context:third-party/class.js";
  private static final String JS_FONT_PICKER_PATH =
"context:third-party/fontselector/src/jquery.fontselector.js";
  private static final String JS_DATE_FORMAT_PATH =
"context:third-party/dateFormat.js";

  @Contribute(ModuleManager.class)
  public static void
addExternalNonAmdJavaScript(MappedConfiguration
configuration,
  @Path(MODERNIZR_PATH) Resource modernizr,
  @Path(JS_SIMPLE_CLASS_PATH) Resource simpleClass
  @Path(JS_FONT_PICKER_PATH) Resource fontPicker,
  @Path(JS_DATE_FORMAT_PATH) Resource dateFormat) {

configuration.add("modernizr",
new JavaScriptModuleConfiguration(modernizr)
.exports("Modernizr"));

configuration.add("class", new
JavaScriptModuleConfiguration(simpleClass)
.exports("Class"));

configuration.add("font-picker", new
JavaScriptModuleConfiguration(fontPicker)
.dependsOn("jquery"));

configuration.add("date-format", new
JavaScriptModuleConfiguration(dateFormat)
.exports("DateFormat")
  .dependsOn("jquery"));

  }
}

Kind regards


2015-02-18 15:04 GMT+01:00 Geoff Callender <
geoff.callender.jumpst...@gmail.com>:

> Hi Diego,
>
> That sounds good, but can you give a concrete example of some code, like I
> gave below. That would be great.
>
> Geoff
>
>
> On 19 Feb 2015, at 1:00 am, Diego Socaceti  wrote:
>
> > sorry, copy, paste-error
> >
> > ... use JavaScriptModuleConfiguration#exports() for 'exports' of shim
> config
> >
> > 2015-02-18 14:58 GMT+01:00 Diego Socaceti :
> >
> >> Hi @all,
> >>
> >> if you want to shim non-AMD JavaScript files you should use
> >> JavaScriptModuleConfiguration.
> >> It offers everything you need to create shim configs.
> >>
> >> use JavaScriptModuleConfiguration#dependsOn() for 'deps' of shim config
> >> use JavaScriptModuleConfiguration#dependsOn() for 'exports' of shim
> config
> >>
> >> Kind regards
> >>
> >>
> >> 2015-02-18 12:13 GMT+01:00 Geoff Callender <
> >> geoff.callender.jumpst...@gmail.com>:
> >>
> >>> Despite what I said 9 months ago in the thread you referenced, I'm not
> >>> sure that I've ever seen the shimming [1] ever work, but I haven't
> pursued
> >>> it because the many javascript libraries I use work fine anyway without
> >>> being modules.
> >>>
> >>> [1]
> >>>
> http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/services/javascript/JavaScriptModuleConfiguration.html
> >>>
> >>> Here are 4 very different examples that my modules are using without, I
> >>> believe, shimming. Maybe they're being shimmed and I should take
> advantage
> >>> of it. If so, I'd welcome someone setting me straight.
> >>>
> >>>public static void contributeModuleManager(
> >>>MappedConfiguration
> configuration,
> >>>
> >>> @Path("/META-INF/assets/js/highcharts-4.0.4/highcharts.js") Resource
> >>> highcharts,
> >>>
> >>> @Path("/META-INF/assets/fineuploader/fineuploader-5.0.9.js") Resource
> >>> fineuploader,
> >>>
> >>> @Path("/META-INF/assets/js/fastclick-1.0.3.min.js") Resource fastclick,
> >>>
> >>>
> @Path("/META-INF/assets/js/pick-a-color-1.2.3/dependencies/tinycolor-0.9.15.min.js")
> >>> Resource tinycolor,
> >>> ) {
> >>>configuration.add("highcharts", new
> >>> JavaScriptModuleConfiguration(highcharts));
> >>>configuration.add("fineuploader", new
> >>> JavaScriptModuleConfiguration(fineuploader));
> >>>configuration.add("fastclick", new
> >>> JavaScriptModuleConfiguration(fastclick));
> >>>configuration.add("tinycolor", new
> >>> JavaScriptModuleConfiguration(tinycolor));
> >>>}
> >>>
> >>> Using highcharts...
> >>>
> >>> define([ "jquery", "highcharts" ], function($) {
> >>>init = function(params) {
> >&

Re: Trying to load non AMD javascript in tapestry 5.4

2015-02-18 Thread Geoff Callender
Hi Diego,

That sounds good, but can you give a concrete example of some code, like I gave 
below. That would be great.

Geoff


On 19 Feb 2015, at 1:00 am, Diego Socaceti  wrote:

> sorry, copy, paste-error
> 
> ... use JavaScriptModuleConfiguration#exports() for 'exports' of shim config
> 
> 2015-02-18 14:58 GMT+01:00 Diego Socaceti :
> 
>> Hi @all,
>> 
>> if you want to shim non-AMD JavaScript files you should use
>> JavaScriptModuleConfiguration.
>> It offers everything you need to create shim configs.
>> 
>> use JavaScriptModuleConfiguration#dependsOn() for 'deps' of shim config
>> use JavaScriptModuleConfiguration#dependsOn() for 'exports' of shim config
>> 
>> Kind regards
>> 
>> 
>> 2015-02-18 12:13 GMT+01:00 Geoff Callender <
>> geoff.callender.jumpst...@gmail.com>:
>> 
>>> Despite what I said 9 months ago in the thread you referenced, I'm not
>>> sure that I've ever seen the shimming [1] ever work, but I haven't pursued
>>> it because the many javascript libraries I use work fine anyway without
>>> being modules.
>>> 
>>> [1]
>>> http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/services/javascript/JavaScriptModuleConfiguration.html
>>> 
>>> Here are 4 very different examples that my modules are using without, I
>>> believe, shimming. Maybe they're being shimmed and I should take advantage
>>> of it. If so, I'd welcome someone setting me straight.
>>> 
>>>public static void contributeModuleManager(
>>>MappedConfiguration configuration,
>>> 
>>> @Path("/META-INF/assets/js/highcharts-4.0.4/highcharts.js") Resource
>>> highcharts,
>>> 
>>> @Path("/META-INF/assets/fineuploader/fineuploader-5.0.9.js") Resource
>>> fineuploader,
>>> 
>>> @Path("/META-INF/assets/js/fastclick-1.0.3.min.js") Resource fastclick,
>>> 
>>> @Path("/META-INF/assets/js/pick-a-color-1.2.3/dependencies/tinycolor-0.9.15.min.js")
>>> Resource tinycolor,
>>> ) {
>>>configuration.add("highcharts", new
>>> JavaScriptModuleConfiguration(highcharts));
>>>configuration.add("fineuploader", new
>>> JavaScriptModuleConfiguration(fineuploader));
>>>configuration.add("fastclick", new
>>> JavaScriptModuleConfiguration(fastclick));
>>>configuration.add("tinycolor", new
>>> JavaScriptModuleConfiguration(tinycolor));
>>>}
>>> 
>>> Using highcharts...
>>> 
>>> define([ "jquery", "highcharts" ], function($) {
>>>init = function(params) {
>>>$chart = $("#" + params.id);
>>>$chart.highcharts({
>>>:
>>> 
>>> Using fineuploader...
>>> 
>>> define(["jquery", "t5/core/console", "fineuploader"], function($,
>>> console) {
>>>var uploader;
>>>init = function(params) {
>>>uploader = new qq.FineUploader({
>>>:
>>> 
>>> Using fastclick...
>>> 
>>> define([ "jquery", "fastclick" ], function($, FastClick) {
>>>return function(options) {
>>>var options = options || {};
>>>new FastClick(document.body, options);
>>>};
>>> });
>>> 
>>> Using tinycolor...
>>> 
>>> // Depends on PickAColorJavaScriptStack.
>>> 
>>> define(["jquery", "tinycolor", "underscore", "t5/core/console",
>>> "bootstrap/tooltip", "bootstrap/popover"], function($, tinycolor, _,
>>> console) {
>>>init = function(params) {
>>>pickAColorOptions = _.extend({},
>>> params.pickAColorOptions);
>>>// To prevent pickAColor failing with "tinycolor is not
>>> defined", assign window.tinycolor.
>>>window.tinycolor = tinycolor;
>>>:
>>> 
>>> HTH,
>>> 
>>> Geoff
>>> 
>>> 
>>> On 18 Feb 2015, at 5:54 pm, abangkis  wrote:
>>> 
>>>> Hi  Geoff. You are right. I can call the showMe() method as a global
>>>> fun

Re: Trying to load non AMD javascript in tapestry 5.4

2015-02-18 Thread Diego Socaceti
sorry, copy, paste-error

... use JavaScriptModuleConfiguration#exports() for 'exports' of shim config

2015-02-18 14:58 GMT+01:00 Diego Socaceti :

> Hi @all,
>
> if you want to shim non-AMD JavaScript files you should use
> JavaScriptModuleConfiguration.
> It offers everything you need to create shim configs.
>
> use JavaScriptModuleConfiguration#dependsOn() for 'deps' of shim config
> use JavaScriptModuleConfiguration#dependsOn() for 'exports' of shim config
>
> Kind regards
>
>
> 2015-02-18 12:13 GMT+01:00 Geoff Callender <
> geoff.callender.jumpst...@gmail.com>:
>
>> Despite what I said 9 months ago in the thread you referenced, I'm not
>> sure that I've ever seen the shimming [1] ever work, but I haven't pursued
>> it because the many javascript libraries I use work fine anyway without
>> being modules.
>>
>> [1]
>> http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/services/javascript/JavaScriptModuleConfiguration.html
>>
>> Here are 4 very different examples that my modules are using without, I
>> believe, shimming. Maybe they're being shimmed and I should take advantage
>> of it. If so, I'd welcome someone setting me straight.
>>
>> public static void contributeModuleManager(
>> MappedConfiguration configuration,
>>
>> @Path("/META-INF/assets/js/highcharts-4.0.4/highcharts.js") Resource
>> highcharts,
>>
>> @Path("/META-INF/assets/fineuploader/fineuploader-5.0.9.js") Resource
>> fineuploader,
>>
>> @Path("/META-INF/assets/js/fastclick-1.0.3.min.js") Resource fastclick,
>>
>> @Path("/META-INF/assets/js/pick-a-color-1.2.3/dependencies/tinycolor-0.9.15.min.js")
>> Resource tinycolor,
>> ) {
>> configuration.add("highcharts", new
>> JavaScriptModuleConfiguration(highcharts));
>> configuration.add("fineuploader", new
>> JavaScriptModuleConfiguration(fineuploader));
>> configuration.add("fastclick", new
>> JavaScriptModuleConfiguration(fastclick));
>> configuration.add("tinycolor", new
>> JavaScriptModuleConfiguration(tinycolor));
>> }
>>
>> Using highcharts...
>>
>> define([ "jquery", "highcharts" ], function($) {
>> init = function(params) {
>> $chart = $("#" + params.id);
>> $chart.highcharts({
>> :
>>
>> Using fineuploader...
>>
>> define(["jquery", "t5/core/console", "fineuploader"], function($,
>> console) {
>> var uploader;
>> init = function(params) {
>> uploader = new qq.FineUploader({
>> :
>>
>> Using fastclick...
>>
>> define([ "jquery", "fastclick" ], function($, FastClick) {
>> return function(options) {
>> var options = options || {};
>> new FastClick(document.body, options);
>> };
>> });
>>
>> Using tinycolor...
>>
>> // Depends on PickAColorJavaScriptStack.
>>
>> define(["jquery", "tinycolor", "underscore", "t5/core/console",
>> "bootstrap/tooltip", "bootstrap/popover"], function($, tinycolor, _,
>> console) {
>> init = function(params) {
>> pickAColorOptions = _.extend({},
>> params.pickAColorOptions);
>> // To prevent pickAColor failing with "tinycolor is not
>> defined", assign window.tinycolor.
>> window.tinycolor = tinycolor;
>> :
>>
>> HTH,
>>
>> Geoff
>>
>>
>> On 18 Feb 2015, at 5:54 pm, abangkis  wrote:
>>
>> > Hi  Geoff. You are right. I can call the showMe() method as a global
>> > function. So, is it okay if I assume that i could only call the shimmed
>> js
>> > lib through global function?  Since it wouldn't get passed through the
>> > define parameter. Or is my implementation that's incorrect? Is there a
>> > better way (better scoped) to implement this?
>> >
>> > Cheers.
>> >
>> > On Wed, Feb 18, 2015 at 7:33 AM, Geoff Callender <
>> > geoff.callender.jumpst...@gmail.com> wrote:
>> >
>> >> Your "require" has ensured the mytest.js file gets loaded by t

Re: Trying to load non AMD javascript in tapestry 5.4

2015-02-18 Thread Diego Socaceti
Hi @all,

if you want to shim non-AMD JavaScript files you should use
JavaScriptModuleConfiguration.
It offers everything you need to create shim configs.

use JavaScriptModuleConfiguration#dependsOn() for 'deps' of shim config
use JavaScriptModuleConfiguration#dependsOn() for 'exports' of shim config

Kind regards


2015-02-18 12:13 GMT+01:00 Geoff Callender <
geoff.callender.jumpst...@gmail.com>:

> Despite what I said 9 months ago in the thread you referenced, I'm not
> sure that I've ever seen the shimming [1] ever work, but I haven't pursued
> it because the many javascript libraries I use work fine anyway without
> being modules.
>
> [1]
> http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/services/javascript/JavaScriptModuleConfiguration.html
>
> Here are 4 very different examples that my modules are using without, I
> believe, shimming. Maybe they're being shimmed and I should take advantage
> of it. If so, I'd welcome someone setting me straight.
>
> public static void contributeModuleManager(
> MappedConfiguration configuration,
>
> @Path("/META-INF/assets/js/highcharts-4.0.4/highcharts.js") Resource
> highcharts,
>
> @Path("/META-INF/assets/fineuploader/fineuploader-5.0.9.js") Resource
> fineuploader,
>
> @Path("/META-INF/assets/js/fastclick-1.0.3.min.js") Resource fastclick,
>
> @Path("/META-INF/assets/js/pick-a-color-1.2.3/dependencies/tinycolor-0.9.15.min.js")
> Resource tinycolor,
> ) {
> configuration.add("highcharts", new
> JavaScriptModuleConfiguration(highcharts));
> configuration.add("fineuploader", new
> JavaScriptModuleConfiguration(fineuploader));
> configuration.add("fastclick", new
> JavaScriptModuleConfiguration(fastclick));
> configuration.add("tinycolor", new
> JavaScriptModuleConfiguration(tinycolor));
> }
>
> Using highcharts...
>
> define([ "jquery", "highcharts" ], function($) {
> init = function(params) {
> $chart = $("#" + params.id);
> $chart.highcharts({
> :
>
> Using fineuploader...
>
> define(["jquery", "t5/core/console", "fineuploader"], function($, console)
> {
> var uploader;
> init = function(params) {
> uploader = new qq.FineUploader({
> :
>
> Using fastclick...
>
> define([ "jquery", "fastclick" ], function($, FastClick) {
> return function(options) {
> var options = options || {};
> new FastClick(document.body, options);
> };
> });
>
> Using tinycolor...
>
> // Depends on PickAColorJavaScriptStack.
>
> define(["jquery", "tinycolor", "underscore", "t5/core/console",
> "bootstrap/tooltip", "bootstrap/popover"], function($, tinycolor, _,
> console) {
> init = function(params) {
> pickAColorOptions = _.extend({}, params.pickAColorOptions);
> // To prevent pickAColor failing with "tinycolor is not
> defined", assign window.tinycolor.
> window.tinycolor = tinycolor;
> :
>
> HTH,
>
> Geoff
>
>
> On 18 Feb 2015, at 5:54 pm, abangkis  wrote:
>
> > Hi  Geoff. You are right. I can call the showMe() method as a global
> > function. So, is it okay if I assume that i could only call the shimmed
> js
> > lib through global function?  Since it wouldn't get passed through the
> > define parameter. Or is my implementation that's incorrect? Is there a
> > better way (better scoped) to implement this?
> >
> > Cheers.
> >
> > On Wed, Feb 18, 2015 at 7:33 AM, Geoff Callender <
> > geoff.callender.jumpst...@gmail.com> wrote:
> >
> >> Your "require" has ensured the mytest.js file gets loaded by the browser
> >> but the file's contents do not define an AMD module. Therefore the
> scope of
> >> showMe() is global, so I think you'll find you can call showMe() but not
> >> mytest.showMe().
> >>
> >> Geoff
> >>
> >> On 18 Feb 2015, at 5:05 am, Thiago H de Paula Figueiredo <
> >> thiag...@gmail.com> wrote:
> >>
> >>> Please read the Require.js documentation about this. You just cannot
> use
> >> Require.js with non AMD .js files and expect it to work without no
> further
> >> work

Re: Trying to load non AMD javascript in tapestry 5.4

2015-02-18 Thread Geoff Callender
Despite what I said 9 months ago in the thread you referenced, I'm not sure 
that I've ever seen the shimming [1] ever work, but I haven't pursued it 
because the many javascript libraries I use work fine anyway without being 
modules.

[1] 
http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/services/javascript/JavaScriptModuleConfiguration.html

Here are 4 very different examples that my modules are using without, I 
believe, shimming. Maybe they're being shimmed and I should take advantage of 
it. If so, I'd welcome someone setting me straight.

public static void contributeModuleManager(
MappedConfiguration configuration,

@Path("/META-INF/assets/js/highcharts-4.0.4/highcharts.js") Resource highcharts,

@Path("/META-INF/assets/fineuploader/fineuploader-5.0.9.js") Resource 
fineuploader,
@Path("/META-INF/assets/js/fastclick-1.0.3.min.js") 
Resource fastclick,

@Path("/META-INF/assets/js/pick-a-color-1.2.3/dependencies/tinycolor-0.9.15.min.js")
 Resource tinycolor,
) {
configuration.add("highcharts", new 
JavaScriptModuleConfiguration(highcharts));
configuration.add("fineuploader", new 
JavaScriptModuleConfiguration(fineuploader));
configuration.add("fastclick", new 
JavaScriptModuleConfiguration(fastclick));
configuration.add("tinycolor", new 
JavaScriptModuleConfiguration(tinycolor));
}

Using highcharts...

define([ "jquery", "highcharts" ], function($) {
init = function(params) {
$chart = $("#" + params.id);
$chart.highcharts({
:

Using fineuploader...

define(["jquery", "t5/core/console", "fineuploader"], function($, console) {
var uploader;
init = function(params) {
uploader = new qq.FineUploader({
:

Using fastclick...

define([ "jquery", "fastclick" ], function($, FastClick) {
return function(options) {
var options = options || {};
new FastClick(document.body, options);
};
});

Using tinycolor...

// Depends on PickAColorJavaScriptStack.

define(["jquery", "tinycolor", "underscore", "t5/core/console", 
"bootstrap/tooltip", "bootstrap/popover"], function($, tinycolor, _, console) {
init = function(params) {
pickAColorOptions = _.extend({}, params.pickAColorOptions);
// To prevent pickAColor failing with "tinycolor is not 
defined", assign window.tinycolor.
window.tinycolor = tinycolor;
:

HTH,

Geoff


On 18 Feb 2015, at 5:54 pm, abangkis  wrote:

> Hi  Geoff. You are right. I can call the showMe() method as a global
> function. So, is it okay if I assume that i could only call the shimmed js
> lib through global function?  Since it wouldn't get passed through the
> define parameter. Or is my implementation that's incorrect? Is there a
> better way (better scoped) to implement this?
> 
> Cheers.
> 
> On Wed, Feb 18, 2015 at 7:33 AM, Geoff Callender <
> geoff.callender.jumpst...@gmail.com> wrote:
> 
>> Your "require" has ensured the mytest.js file gets loaded by the browser
>> but the file's contents do not define an AMD module. Therefore the scope of
>> showMe() is global, so I think you'll find you can call showMe() but not
>> mytest.showMe().
>> 
>> Geoff
>> 
>> On 18 Feb 2015, at 5:05 am, Thiago H de Paula Figueiredo <
>> thiag...@gmail.com> wrote:
>> 
>>> Please read the Require.js documentation about this. You just cannot use
>> Require.js with non AMD .js files and expect it to work without no further
>> work.
>>> 
>>> On Sat, 14 Feb 2015 14:04:36 -0200, abangkis  wrote:
>>> 
>>>> Hello. I'm trying to load a simple regular javascript that's going to be
>>>> used as dependency from a RequireJS module.
>>>> 
>>>> So i created mytest.js under classpath:META-INF/assets/js/mytest.js. It
>>>> contain a single function :
>>>> 
>>>> function showMe() {
>>>> alert("test 2  my_test");
>>>> };
>>>> 
>>>> I add the contribution in AppModule
>>>> 
>>>>   public static void
>> contributeModuleManager(MappedConfiguration>>> Object> configuration,
>>>>   @Path("/META-INF/assets/js/mytest.js") Resource js) {
>

Re: Trying to load non AMD javascript in tapestry 5.4

2015-02-17 Thread abangkis
Hi  Geoff. You are right. I can call the showMe() method as a global
function. So, is it okay if I assume that i could only call the shimmed js
lib through global function?  Since it wouldn't get passed through the
define parameter. Or is my implementation that's incorrect? Is there a
better way (better scoped) to implement this?

Cheers.

On Wed, Feb 18, 2015 at 7:33 AM, Geoff Callender <
geoff.callender.jumpst...@gmail.com> wrote:

> Your "require" has ensured the mytest.js file gets loaded by the browser
> but the file's contents do not define an AMD module. Therefore the scope of
> showMe() is global, so I think you'll find you can call showMe() but not
> mytest.showMe().
>
> Geoff
>
> On 18 Feb 2015, at 5:05 am, Thiago H de Paula Figueiredo <
> thiag...@gmail.com> wrote:
>
> > Please read the Require.js documentation about this. You just cannot use
> Require.js with non AMD .js files and expect it to work without no further
> work.
> >
> > On Sat, 14 Feb 2015 14:04:36 -0200, abangkis  wrote:
> >
> >> Hello. I'm trying to load a simple regular javascript that's going to be
> >> used as dependency from a RequireJS module.
> >>
> >> So i created mytest.js under classpath:META-INF/assets/js/mytest.js. It
> >> contain a single function :
> >>
> >> function showMe() {
> >> alert("test 2  my_test");
> >> };
> >>
> >> I add the contribution in AppModule
> >>
> >>public static void
> contributeModuleManager(MappedConfiguration >> Object> configuration,
> >>@Path("/META-INF/assets/js/mytest.js") Resource js) {
> >>configuration.add("mytest", new
> JavaScriptModuleConfiguration(js));
> >>}
> >>
> >> Create a test page
> >>
> >> @Import(module = "Lima")
> >> public class Lima {
> >> }
> >>
> >> that call the module :
> >>
> >> require(['mytest'],
> >> function(mytest){
> >> console.log("mytest " + mytest);
> >> mytest.showMe();
> >> });
> >>
> >> the module is loaded, the mytest.js file is found. But the console log
> >> mytest as undefined. Here's what's printed on the console
> >>
> >> Loading 2 libraries
> >> console.js:104 Loading library
> >> /KomuttaCentral/assets/ctx/z1d218c13/js/jquery-2.0.3.min.js
> >> console.js:104 Loading library
> >> /KomuttaCentral/assets/ctx/z50c3674f/js/scripts.js
> >> console.js:104 Executing 1 inits
> >> console.js:104 Loaded module Lima
> >> console.js:104 All inits executed
> >> Lima.js:3 mytest undefined
> >> console.js:104 RequireJS error: require: Cannot read property 'showMe'
> of
> >> undefined
> >>
> >> So, what did i do wrong? Thanks.
> >
> >
> > --
> > Thiago H. de Paula Figueiredo
> > Tapestry, Java and Hibernate consultant and developer
> > http://machina.com.br
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> > For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
http://www.mreunionlabs.net/ <http://www.mreunion-labs.net/>
twitter : @mreunionlabs @abangkis
page : https://plus.google.com/104168782385184990771


  1   2   3   4   5   6   7   8   9   10   >