Re: redirect from ajax request

2009-08-10 Thread Mario Rabe
Actually its was pretty easy (like most things I try to do with tapestry) as
soon as I understand the concept. Simply getting the
current ComponentEventResultProcessor from the Environment, wrap it in case
of exceptions and let it process the return-value. It is really as easy as
this, EXCEPT you use the processor AND return a value after that.
This way I managed it to have 2 json-objects in the response which made
tapestry.js really mad =D

{redirectURL:/TapTestReal/about}{content:And another counter: 11}


public class Counter {

@InjectComponent
private Zone countzone;

@Inject
private ComponentResources componentResources;

@Environmental
private ComponentEventResultProcessor componentEventResultProcessor;

@Property
@Persist
private int count;

private Object fireValueChanged() throws IOException {
ComponentResultProcessorWrapper callback = new
ComponentResultProcessorWrapper(componentEventResultProcessor);
componentResources.triggerEvent(valueChanged, new Object[]{new
Integer(count)}, callback);
if (!callback.isAborted()) {
return countzone.getBody();
}
return null;
}

public Object onUp() throws IOException {
count++;
return fireValueChanged();
}

public Object onDown() throws IOException {
count--;
return fireValueChanged();
}

public Object onReset() throws IOException {
count = 0;
return fireValueChanged();
}

public String getZoneId(){
return countzone.getClientId();  //with this I can use this
component multiple times on a single page even with ajax enabled
}
}

I cutted some pieces of code which implement features not used in this
context, hopefully it still compiles. That component can be used on a page
like:

Object onValueChangedFromEggCounter(int value){
if(value  10)
return ToMuchEggs.class;
return null;
}

and everything works like expected (if counter reaches 11 you are redirected
to another page).

- Mario

2009/8/10 Howard Lewis Ship hls...@gmail.com

 To be specific, when during an Ajax request the component even returns
 a page class or page instance, Tapestry builds and returns a Link as
 part of the JSON response, the the client-side loads that Link's URL
 into the browser address, performing a redirect.

 There are two implementations of ComponentEventResultProcessor, one
 for @Traditional and one for @Ajax ... just bear that in mind if you
 want to read the existing code, or extend the current behavior. They
 are both based on a mapped configuration from return type to a
 handler.

 On Sun, Aug 9, 2009 at 5:34 PM, Thiago H. de Paula
 Figueiredothiag...@gmail.com wrote:
  Em Sat, 08 Aug 2009 15:26:45 -0300, Mario Rabe 
 mario.r...@googlemail.com
  escreveu:
 
  Hi,
 
  Hi!
 
  how can I do a redirect from a XHR-request? Here an example to make
 clear
  what I want to do:
 
  If it was a Tapestry-provided event, you could just return a page
 instance,
  a page class, an URL or a page name in an event handler method.
  Looking at the Form component sources, it uses this callback instance in
 its
  VALIDATE_FORM event:
 
  ComponentResultProcessorWrapper callback = new
  ComponentResultProcessorWrapper(componentEventResultProcessor);
 
  componentEventResultProcessor comes from an environmental service:
 
  @Environmental
  private ComponentEventResultProcessor componentEventResultProcessor;
 
  Try using the above callback and please post the results. :)
 
  --
  Thiago H. de Paula Figueiredo
  Independent Java consultant, developer, and instructor
  http://www.arsmachina.com.br/thiago
 
  -
  To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
  For additional commands, e-mail: users-h...@tapestry.apache.org
 
 



 --
 Howard M. Lewis Ship

 Creator of Apache Tapestry
 Director of Open Source Technology at Formos

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




redirect from ajax request

2009-08-08 Thread Mario Rabe
Hi,
how can I do a redirect from a XHR-request? Here an example to make clear
what I want to do:

I've got a couter-component which shows a count and 2 links (up and down).
If a link is clicked, the count is changed inPlace. A ValueChanged-Event
is triggered on every change.

[Pseudo-Code. won't compile, just to show the intention]
class Counter{
@Property private int count;

EventCallback callback = new EventCallback(){
boolean handleEvent(...){
...
}
};

onUp(){
count++;
resources.triggerEvent(valueChanged, new Object[]{count},
callback);
}
onDown(){
count--;
resources.triggerEvent(valueChanged, new Object[]{count},
callback);
}
}


That counter can be used on pages and the page can do something if user
changes value.

class CounterPage{

 Object onValueChangeFromMyCounter(int count){
  if(count  Oracle.MYSTICAL_VALUE){
System.secretOperation();
  }
 }

}

Now my question is how to do a page-redirect in the EventListener on the
page? I can return an URL from it but to do with it in the callback? Which
service is responsible? And does tapestry.js handle redirects in
XHR-requests as W3C-XHR doesn't?

Greetings

Mario


Re: Web framework evaluation - What is beautiful in Tapestry?

2009-04-24 Thread Mario Rabe
I like the amount of predictable magic the framework does. Thats what
enables you writing much less code compared to others. You write the parts
of your web-app that differ from the common case and T5 clues them
together working app with some best-practices implemented for free.
Howard calls this magic adaptive API, and thats in fact by far the
greatest invention I've seen last years.

Well thats the what. The how (you've to check this out your self) is
interesting too: Since the logical design of T5 many different developers
solve problems in similar ways, simpy cause they start thinking in T5. Do I
have to say what this means for large teams?

Best Regards / Mit freundlichen Grüßen

Mario Rabe

2009/4/23 Sebastian Hennebrueder use...@laliluna.de

 Sebastian Hennebrueder wrote:

 Hello,

 Sorry, the question should be of course:

 What is your favourite feature or concept of Tapestry, what is unique as
 compared to other things, what is an eye catcher?


 --
 Best Regards / Viele Grüße

 Sebastian Hennebrueder
 -
 Software Developer and Trainer for Hibernate / Java Persistence
 http://www.laliluna.de




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




Reloading in 5.1

2009-04-05 Thread Mario Rabe
I noticed tapestry5.1 doesn't reload anything anymore in an existing
project. To check things out I created the tap5.1-quickstart-app and tested
it with it. Same result! No changes are picked up. Not from classes and not
from templates. I've tested it with Netbeans-IDE using tomcat and
glassfishv3 as well as jetty:run.
I've patched the Template-Loaders to output the path from which the template
is loaded and it shows the correct path (not accidently packed them into an
archive or the such).
I even had an error in an template where i've forgotten to set a required
property. The error-page shows the part of template where the error occured
(indeed a pretty cool feature) and if I change the template in the place
tapestry has loaded it, I get the absolutely same error-message but the part
of the template updated as i changed it. I have to restart the app to have
tapestry pickup the changes.

Is this a known issue? Does anyone has a clue for me where to look at?

Mario


changing template-extension

2009-04-05 Thread Mario Rabe
Why is it so hard to change the default-template extension? I really want
the templates to end with html! The I saw the template-extension is
defined as a constant. It is even inlined in classes.
ComponentTemplateSource#baseResourceForModel is private so there is no
override. Beside that ComponentTemplateSource is final. Similar problems
with PageTemplateLocator.

So to change the extension from tml to html I have to copy 2 internal
classes, change them slightly and override the internal services.

Thats not very tapestry in my oppinion. There should be a symbol in the core
which defines an alternative extension for templates. If a template could
not be found using the default-extension then the alternative extension is
checked before loading fails. Code could look like:

Resource res =
model.getBaseResource().withExtension(InternalConstants.TEMPLATE_EXTENSION);
if(res.toURL()!=null){
return res;
}
return model.getBaseResource().withExtension(altenativeExtension);

Maybe there is a more effective way to provide such a feature using
module-scopes. What do you think about it?

Mario


Re: changing template-extension

2009-04-05 Thread Mario Rabe
Not true, it could be handled as a fallback (see code).

2009/4/5 Joachim Van der Auwera joac...@progs.be

 Changing the template extension would render all component libraries (which
 use templates) unusable. Not that this is impossible to fix, but it a
 complication.

 Kind regards,
 Joachim


 Mario Rabe wrote:

 Why is it so hard to change the default-template extension? I really want
 the templates to end with html! The I saw the template-extension is
 defined as a constant. It is even inlined in classes.
 ComponentTemplateSource#baseResourceForModel is private so there is no
 override. Beside that ComponentTemplateSource is final. Similar problems
 with PageTemplateLocator.

 So to change the extension from tml to html I have to copy 2 internal
 classes, change them slightly and override the internal services.

 Thats not very tapestry in my oppinion. There should be a symbol in the
 core
 which defines an alternative extension for templates. If a template could
 not be found using the default-extension then the alternative extension is
 checked before loading fails. Code could look like:

Resource res =

 model.getBaseResource().withExtension(InternalConstants.TEMPLATE_EXTENSION);
if(res.toURL()!=null){
return res;
}
return model.getBaseResource().withExtension(altenativeExtension);

 Maybe there is a more effective way to provide such a feature using
 module-scopes. What do you think about it?

 Mario





 --
 Joachim Van der Auwera
 PROGS bvba, progs.be


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




Re: changing template-extension

2009-04-05 Thread Mario Rabe
I just think it's easy enough given the enhancement that you can use own
extensions without having to sync TemplateLocators with trunk!

2009/4/5 Mario Rabe mario.r...@googlemail.com

 Not true, it could be handled as a fallback (see code).

 2009/4/5 Joachim Van der Auwera joac...@progs.be

 Changing the template extension would render all component libraries (which
 use templates) unusable. Not that this is impossible to fix, but it a
 complication.

 Kind regards,
 Joachim


 Mario Rabe wrote:

 Why is it so hard to change the default-template extension? I really want
 the templates to end with html! The I saw the template-extension is
 defined as a constant. It is even inlined in classes.
 ComponentTemplateSource#baseResourceForModel is private so there is no
 override. Beside that ComponentTemplateSource is final. Similar problems
 with PageTemplateLocator.

 So to change the extension from tml to html I have to copy 2 internal
 classes, change them slightly and override the internal services.

 Thats not very tapestry in my oppinion. There should be a symbol in the
 core
 which defines an alternative extension for templates. If a template could
 not be found using the default-extension then the alternative extension
 is
 checked before loading fails. Code could look like:

Resource res =

 model.getBaseResource().withExtension(InternalConstants.TEMPLATE_EXTENSION);
if(res.toURL()!=null){
return res;
}
return model.getBaseResource().withExtension(altenativeExtension);

 Maybe there is a more effective way to provide such a feature using
 module-scopes. What do you think about it?

 Mario





 --
 Joachim Van der Auwera
 PROGS bvba, progs.be


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





Re: Reloading in 5.1

2009-04-05 Thread Mario Rabe
I noticed it works sometimes for templates (even in Netbeans with
glassfish!) but not often. Haven't figured out where the differeces are.

2009/4/5 Andy Pahne andy.pa...@googlemail.com


 Works here... (jetty:run, T 5.1.0.2 and T 5.1.0.3-SNAPSHOT).

 Most of the time when I had issues with life reloading, it was related to
 Eclipse or maven...

 Andy



 Mario Rabe schrieb:

  I noticed tapestry5.1 doesn't reload anything anymore in an existing
 project. To check things out I created the tap5.1-quickstart-app and
 tested
 it with it. Same result! No changes are picked up. Not from classes and
 not
 from templates. I've tested it with Netbeans-IDE using tomcat and
 glassfishv3 as well as jetty:run.
 I've patched the Template-Loaders to output the path from which the
 template
 is loaded and it shows the correct path (not accidently packed them into
 an
 archive or the such).
 I even had an error in an template where i've forgotten to set a required
 property. The error-page shows the part of template where the error
 occured
 (indeed a pretty cool feature) and if I change the template in the place
 tapestry has loaded it, I get the absolutely same error-message but the
 part
 of the template updated as i changed it. I have to restart the app to have
 tapestry pickup the changes.

 Is this a known issue? Does anyone has a clue for me where to look at?

 Mario





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