Re: Dynamic form

2010-09-17 Thread Антон Мезерный
And what is the best way to create such a dynamic form? Using Delegate
component or modifying beaneditform? Or maybe there is better approach?

I tried to write it using Delegate and I have a problem - I can't get
component instance from ComponentSource - Exception:

org.apache.tapestry5.internal.services.RenderQueueException
Render queue error in BeginRender[Step:dynamicformfield.delegate]: Failure
reading parameter 'to' of component Step:dynamicformfield.delegate: Unable
to resolve 'textfield' to a known page name. Available page names: (blank),
About, Contact, ExceptionReport, Index, PropertyDisplayBlocks,
PropertyEditBlocks, ServiceStatus, Step.

Why is it looking for a page, not component?

2010/9/17 Thiago H. de Paula Figueiredo 

> On Thu, 16 Sep 2010 19:09:05 -0300, Антон Мезерный <
> anton.meze...@gmail.com> wrote:
>
>  Hello,
>>
>
> Hi!
>
>
>  I am trying to make a dynamic form component, something like beaneditform,
>> but based not on bean field type, but on some property in database.
>>
>
> I strongly advise you to read the BeanEditor sources and do something
> similar or, better yet, contribute viewing and edition blocks. The end of
> this page shows you how to add blocks:
> http://tapestry.apache.org/tapestry5.1/guide/beaneditform.html. Besides
> that, create one of more DataTypeAnalyzer and contribute them to the
> DataTypeAnalyzer service. See
> http://tapestry.1045711.n5.nabble.com/Custom-Edit-Block-td2427355.html for
> a little more detail.
>
>
>  Another words I want to create something like
>> 
>>
>
> Short answer: you can't. Tapestry pages and components have stricly static
> structure.
> Long answer: you can use blocks () and the Delegate component to
> render blocks or components dynamically.
>
>
>  I tried to use delegate component, but as I understood, I should define
>> all my components (inputs and other) inside one tml-page in block tags and
>>
>
> Not necessarily in a single page.
>
>
>  create block instances in java code. Can I do that with separate
>> components for every element in the form?
>>
>
> Yes.
>
>
>  What is the best way to achieve it?
>>
>
> ComponentSource will help you to grab page instances.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: how to cleanup threads when tapestry shutsdown

2010-09-17 Thread Howard Lewis Ship
Added to FAQ:

https://cwiki.apache.org/confluence/display/TAPESTRY/Frequently+Asked+Questions#FrequentlyAskedQuestions-Myservicestartsathread%3BhowdoIknowwhentheapplicationisshuttingdown%2Ctostopthatthread%3F


On Fri, Sep 17, 2010 at 2:33 PM, Howard Lewis Ship  wrote:
> This is not a discussion for the dev list; it should be on the users list.
>
> On Fri, Sep 17, 2010 at 12:13 PM, Dmitry Gusev  wrote:
>> Contribute RegistryShutdownListener like this:
>>
>>    public MyClass buildMyClass(RegistryShutdownHub hub)
>>    {
>>        MyClass result = new MyClass();
>>
>>        // MyClass should implement RegistryShutdownListener interface
>>
>>        hub.addRegistryShutdownListener(result);
>>
>>        return result;
>>    }
>>
>> On Fri, Sep 17, 2010 at 21:02, hese <1024h...@gmail.com> wrote:
>>
>>>
>>> Hi,
>>>
>>> I have written a tapestry service and added it to AppModule.java (using
>>> function buildMyClass()).  This service class uses a thread to execute some
>>> processes.  Now, the question is how do I know if the web app/tapestry is
>>> shutting down so that I can do clean up stuff in my class??
>>>
>>> Thanks!
>>> hese.
>>> --
>>> View this message in context:
>>> http://tapestry.1045711.n5.nabble.com/how-to-cleanup-threads-when-tapestry-shutsdown-tp2844012p2844012.html
>>> Sent from the Tapestry - Dev mailing list archive at Nabble.com.
>>>
>>> -
>>> To unsubscribe, e-mail: dev-unsubscr...@tapestry.apache.org
>>> For additional commands, e-mail: dev-h...@tapestry.apache.org
>>>
>>>
>>
>>
>> --
>> Dmitry Gusev
>>
>> AnjLab Team
>> http://anjlab.com
>>
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator of Apache Tapestry
>
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
>
> (971) 678-5210
> http://howardlewisship.com
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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



Re: [T5.2] JavaScript combination

2010-09-17 Thread Howard Lewis Ship
On Fri, Sep 17, 2010 at 9:20 AM, Blower, Andy
 wrote:
> A few questions:
>
> Is there any documentation of the new JavaScript combination functionality 
> added to fix TAP5-769 in 5.2, specifically about stacks? I can't see any, but 
> before I dive into code/javadoc I thought I'd ask.

Well, there's JavaDoc.

>
> Why aren't the prototype & scriptaculous libraries combined into a stack by 
> default?
>

They are in production; by default in development the aggregation
logic is turned off, as it makes it much faster/easier to debug on the
client side. There's a symbol you can override to enable aggregation
in development mode.

> What's the status of minifying css & js?
>

No progress on that; concentrating on documentation and getting 5.2
out the door right now.

> Thanks,
>
> Andy.
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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



Re: URL to file

2010-09-17 Thread based2

http://wiki.apache.org/tapestry/Tapestry5HowToStreamAnExistingBinaryFile

== http://wiki.apache.org/tapestry/Tapestry5HowTos
== http://wiki.apache.org/tapestry/Tapestry5OpensourceApps
== http://wiki.apache.org/tapestry/Tapestry5ModuleRegistry
http://people.apache.org/~uli/tapestry-site/frequently-asked-questions.html#FrequentlyAskedQuestions-HowdoIstoremypageclassesinadifferentpackage
-- 
View this message in context: 
http://tapestry.1045711.n5.nabble.com/URL-to-file-tp2800186p2844332.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Tapestry world tour: San Francisco, London

2010-09-17 Thread Howard Lewis Ship
Just a reminder.  I'll be presenting the Tapestry State of the Union at JavaOne:

Mon Sep 20
8:30 PM
Moscone South room 309

In addition, I'll be teaching a FOUR day Tapestry class for
SkillsMatter, starting October 5th.

This is an expanded and improved version of my Tapestry Workshop; it
now includes a lab devoted to
the testing of Tapestry pages and components.

http://skillsmatter.com/course/java-jee/tapestry-web-development/wd-798

-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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



Re: T5.1: componentSource with an activation context

2010-09-17 Thread Thiago H. de Paula Figueiredo
On Fri, 17 Sep 2010 12:58:52 -0300, Jack Nuzbit   
wrote:



Hi,


Hi!

Is there a way to create Pages and initialise their activation context  
at a service level?


I'm curious about what you're trying to accomplish here. :)

Is there a way I can set an activation/event context in this component  
using existing Tapestry services?


You can try doing exact the same thing components do to trigger events:  
the ComponentResources triggerEvent(...) method in your returned page  
instance. To get the ComponentResources for a given Component, use  
getComponentResources(). Never tried it myself, though.


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

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

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



Re: Blog post about T5 data access layer implementation in GAE

2010-09-17 Thread Dmitry Gusev
Thanks, Michael

I updated the post.
I've heard about Objectify before, but never used it.

On Fri, Sep 17, 2010 at 19:35, Michael Gentry  wrote:

> Hi Dmitry,
>
> You mention there are two ways to communicate with the GAE datastore
> from Java, but there is at least one more:
>
> http://code.google.com/p/objectify-appengine/
>
> I haven't looked into it in detail, but thought I'd mention it for
> yourself and others who might have an interest.
>
> mrg
>
>
> On Wed, Sep 1, 2010 at 3:54 PM, Dmitry Gusev 
> wrote:
> > FYI
> >
> >
> http://dmitrygusev.blogspot.com/2010/09/gae-and-tapestry5-data-access-layer.html
> >
> > --
> > Dmitry Gusev
> >
> > AnjLab Team
> > http://anjlab.com
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


[T5.2] JavaScript combination

2010-09-17 Thread Blower, Andy
A few questions:

Is there any documentation of the new JavaScript combination functionality 
added to fix TAP5-769 in 5.2, specifically about stacks? I can't see any, but 
before I dive into code/javadoc I thought I'd ask.

Why aren't the prototype & scriptaculous libraries combined into a stack by 
default?

What's the status of minifying css & js?

Thanks,

Andy.


T5.1: componentSource with an activation context

2010-09-17 Thread Jack Nuzbit
Hi,

Is there a way to create Pages and initialise their activation context at a
service level?

ComponentSource can give me Component instances but casting it to my page
instance results in a ClassCastException due to the different classloaders.
Is there a way I can set an activation/event context in this component using
existing Tapestry services?

This thread does mention that I could use an interface defined outside of
the component/page/mixin packages but it feels like there might be a way to
hook into the existing tapestry context behaviour...

http://tapestry.1045711.n5.nabble.com/Tap-5-0-11-How-to-get-page-instance-from-page-tt2416695.html#none

Thanks in advance for any help.

Cheers,

Jack


Re: Blog post about T5 data access layer implementation in GAE

2010-09-17 Thread Michael Gentry
Hi Dmitry,

You mention there are two ways to communicate with the GAE datastore
from Java, but there is at least one more:

http://code.google.com/p/objectify-appengine/

I haven't looked into it in detail, but thought I'd mention it for
yourself and others who might have an interest.

mrg


On Wed, Sep 1, 2010 at 3:54 PM, Dmitry Gusev  wrote:
> FYI
>
> http://dmitrygusev.blogspot.com/2010/09/gae-and-tapestry5-data-access-layer.html
>
> --
> Dmitry Gusev
>
> AnjLab Team
> http://anjlab.com
>

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



Re: SendRedirect is giving NullPointerException

2010-09-17 Thread Thiago H. de Paula Figueiredo
On Fri, 17 Sep 2010 08:25:14 -0300, Duruk_Kab   
wrote:



Hi,


Hi!


I have migrated my application recently from Tapestry 5.0.18 to 5.1.0.5.
I was handling session in my application previously (5.0.18) as:

If (!visitExists) {
  sessionState.setSessionExpired(false);
  _reqestGlobals.getResponse().sendRedirect(pageName); // start page
}


I guess you were a Tapestry 4 user. :)

If you're in page or event handler method, the right way of doing a  
redirect is to return a java.net.URL instance.
By the way, you can inject the Request and Response directly without usin  
RequestGlobals.


My requirement is if session fails, redirect it to start page where it  
will show the message. Please help me to resolve this issue.


This is better implemented in a RequestFilter. There you can use  
sendRedirect() without problems.


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

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

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



Re: NPE in getSession of an anonymous Request class?

2010-09-17 Thread LLTYK

Well it boiled down to the commented out line below. I changed the forward to
the requestGlobals one and it works.


try
{
  requestGlobals.getResponse().sendRedirect("nontapestrypage.html");
 
//request.getRequestDispatcher("nontapestrypage.html").forward(request,
response);
  return null;
} finally {
  redirect = null;
}
-- 
View this message in context: 
http://tapestry-users.832.n2.nabble.com/NPE-in-getSession-of-an-anonymous-Request-class-tp5538899p5542335.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

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



SendRedirect is giving NullPointerException

2010-09-17 Thread Duruk_Kab

Hi,

I have migrated my application recently from Tapestry 5.0.18 to 5.1.0.5.

I was handling session in my application previously (5.0.18) as:

If (!visitExists) {
  sessionState.setSessionExpired(false);
  _reqestGlobals.getResponse().sendRedirect(pageName); // start page
}

but this is not working anymore in 5.1.0.5. I tried with httpServletResponse
or Response as well... but it gave me the same NPE.

My requirement is if session fails, redirect it to start page where it will
show the message. Please help me to resolve this issue.

Thanks,
DK
-- 
View this message in context: 
http://tapestry-users.832.n2.nabble.com/SendRedirect-is-giving-NullPointerException-tp5542265p5542265.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

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



Re: [T5.2] Tapestry IoC Configuration (remove?)

2010-09-17 Thread Michael Dukaczewski
Hi Howard and all,

thanks for your reply. I am always impressed how flexible Tapestry is.
The activation of the compression for JSON worked, but I was struck
by TAP5-469 and started some research.
Regarding your blog post
(http://tapestryjava.blogspot.com/2009/04/is-gzip-compression-compatible-with.html):
I tried several other combinations that worked fine, so I'm convinced
that GZIP compression in combination with JSON content basically works.
Thus, the error seems to be somewhere in the Tapestry code. My research
has shown that the Tapestry gzip stream sometimes does not finish
correctly when sending json. Therefore, the data is broken when it
arrives at the client. I have now solved the problem the following way
and it works very well:

I have changed my event handler from:

JSONObject onAction() {return getJson();}

to:

StreamResponse onAction() {return new JSONResponse(getJson());}

and created the following wrapper:

public class JSONResponse implements StreamResponse {

   private static final int HEADER_SIZE = 20;
   private static final int MIN_DATA_SIZE = 512;
   private static final String CHARSET = "UTF-8";

   private byte[] data;
   private boolean compress;

   public JSONResponse(JSONCollection json) {
   try {
   data = json.toCompactString().getBytes(CHARSET);
   compress = data.length >= MIN_DATA_SIZE;
   } catch (UnsupportedEncodingException e) {
   // should never happen!
   }
   }

   @Override
   public String getContentType() {
   return "application/json; charset="+CHARSET;
   }

   @Override
   public InputStream getStream() throws IOException {
   if (!compress) {
   return new ByteArrayInputStream(data);
   }
   ByteArrayOutputStream out = new ByteArrayOutputStream(
expectedCompressedSize(data.length));
   GZIPOutputStream gzip = new GZIPOutputStream(out);
   gzip.write(data);
   gzip.close();
   byte[] gzipedData = out.toByteArray();
   return new ByteArrayInputStream(gzipedData);
   }

   @Override
   public void prepareResponse(Response response) {
   if (compress) {
   response.setHeader("Content-Encoding", "gzip");
   }
   }

   private int expectedCompressedSize(int size) {
   return (size >> 2) + HEADER_SIZE;
   }

}


Regards,
Michael



Am 16.09.2010 18:03, schrieb Howard Lewis Ship:
> Also, make sure you disable JSON pretty printing!  Most of a JSON
> response is now whitespace when in development mode.
> 
> On Thu, Sep 16, 2010 at 8:59 AM, Howard Lewis Ship  wrote:
>> It's a bit kludgey, but you could decorate the
>> ResponseCompressionAnalyzer service, something like:
>>
>> public ResponseCompressionAnalyzer
>> decorateResonseCompressionAnalyzer(final ResponseCompressionAnalyzer
>> delegate)
>> {
>>  return new REsponseCompressionAnalyzer() {
>>public boolean isGzipSupported() { return delegate.isGzipSupported(); }
>>  public boolean isCompressable(String contentType) {
>>if (contentType.equals("application/json")) return true;
>>
>> return delegate.isCompressable(contentType);
>> }
>> };
>>
>> }
>>
>> On Thu, Sep 16, 2010 at 7:50 AM, Michael Dukaczewski
>>  wrote:
>>> I know. I have been following the topic. But now I have the problem that
>>> I have to transfer very large JSON objects. The application on which I
>>> am working is just for a small group of people (intranet) where I can
>>> make browser decisions. With luck, I can find a configuration that works
>>> well in my case with gzip compression. So is there a way to reactivate it?
>>>
>>>
>>> Am 16.09.2010 16:12, schrieb Thiago H. de Paula Figueiredo:
 On Thu, 16 Sep 2010 10:40:08 -0300, Michael Dukaczewski
  wrote:

> thanks for your answer, but that does not help me.
> Is there a simple workaround to reactivate gzip compression for json?

 It was disabled because it cause problems in some browsers.

>>>
>>> -
>>> 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
>>
>> The source for Tapestry training, mentoring and support. Contact me to
>> learn how I can get you up and productive in Tapestry fast!
>>
>> (971) 678-5210
>> http://howardlewisship.com
>>
> 
> 
> 

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