Re: [T5] Restricting Page Access

2007-08-26 Thread Robin Helgelin
On 8/26/07, Charles Mason <[EMAIL PROTECTED]> wrote:
> I have made my own worker class, annotation and service. I understand
> the acegi worker class except for the transform page part. I can't
> work out how its managing to change the page. Its clearly modifying a
> method but, I cant really work out how.

It's the method transformPage() that actually changes the page. It's
that last call to extendMethod(), that actually adds the call to the
class. It attaches the class begin render and cleanup render. Acegi
double checks things in cleanup whereas you might not need the extra
fields injected earlier in that method.

> The other thing I was struggling with is, how I actually integrate the
> worker in to my service. I have a RequestFilter working from AppModule
> which is executed for every request. But how do I use the worker class
> I have just created? I could just call the transform method, but where
> do I get the ClassTransformation object from. I assume there is some
> correct way to apply a ComponentClassTransformWorker to a component>

Yes, just contribute to the class transform worker, like this, and
Tapestry will take care of running it on your classes.
public static void contributeComponentClassTransformWorker(
OrderedConfiguration
configuration, SecurityChecker securityChecker) {
configuration.add("Acegi", new AcegiWorker(securityChecker));
}

-- 
regards,
Robin

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: Coercion of null to type java.math.BigDecimal (via null --> String, String --> java.math.BigDecimal) failed: java.lang.NullPointerException

2007-08-26 Thread Denny
I am sure my BigDecimal translator is no problem, I have fixed this problem
by modify the Tapestry ioc's source code. ok, here is my translator.


   1. package com.javaeye.dengyin2000.gtts.tapestry;
   2.
   3. import java.math.BigDecimal;
   4.
   5. import org.apache.tapestry.Translator;
   6. import org.apache.tapestry.ValidationException;
   7. import org.apache.tapestry.ioc.Messages;
   8. import org.apache.tapestry.ioc.internal.util.InternalUtils;
   9.
   10. public class BigDecimalTranslator implements
Translator {
   11.
   12. public
BigDecimal parseClient(String clientValue, Messages messages)
   13. throws ValidationException {
   14. if (InternalUtils.isBlank(clientValue))
   15. return null;
   16.
   17. try
   18. {
   19. return new BigDecimal(clientValue.trim());
   20. }
   21. catch (NumberFormatException ex)
   22. {
   23. throw new ValidationException(messages.format(
   "number-format-exception", clientValue));
   24. }
   25. }
   26.
   27. public String toClient(BigDecimal value) {
   28. return value == null ? "" : value.toString();
   29. }
   30.
   31. }

and in AppModule.java


   1. public static void contributeTranslatorDefaultSource(
   2. MappedConfiguration configuration)
   3. {
   4. configuration.add(BigDecimal.class, new
BigDecimalTranslator());
   5. }
   6.
   7. public static void contributeTranslatorSource(
   8. MappedConfiguration configuration)
   9. {
   10. configuration.add("bigdecimal",  new
BigDecimalTranslator());
   11. }

It's a real bug in tapestry ioc 5.0.5.


   1.
   // String to BigDecimal is important, as String->Double->BigDecimal
would lose

   2. // precision.
   3.
   4. add(configuration, String.class, BigDecimal.class, new
Coercion()
   5. {
   6. public BigDecimal coerce(String input)
   7. {
   8. return new BigDecimal(input);
   9. }
   10.

So I modify code to :


   1.
   // String to BigDecimal is important, as String->Double->BigDecimal
would lose

   2. // precision.
   3.
   4. add(configuration, String.class, BigDecimal.class, new
Coercion()
   5. {
   6. public BigDecimal coerce(String input)
   7. {
   8. if (input == null || input.trim().length() == 0)
   9. return null;
   10. return new BigDecimal(input);
   11. }
   12. });


And the problem has gone.




On 8/27/07, Nick Westgate <[EMAIL PROTECTED]> wrote:
>
> Please show the code for your translator.
>
> Cheers,
> Nick.
>
>
> Denny wrote:
> > I have contribute a BigDecimal translator, Yes, I know it's a T5 bug and
> it
> > would be fix in version 5.0.6. I searched tapestry mailling list, but I
> > haven't gotten the answer. Does anybody know how to fix it? do your guys
> > don't meet this problem. Or I should modify the T5.0.5' source code?
> >
> > Thanks.
> >
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Regards

Denny
Site: http://dengyin2000.javaeye.com


Re: T5: Coercion of null to type java.math.BigDecimal (via null --> String, String --> java.math.BigDecimal) failed: java.lang.NullPointerException

2007-08-26 Thread Nick Westgate

Please show the code for your translator.

Cheers,
Nick.


Denny wrote:

I have contribute a BigDecimal translator, Yes, I know it's a T5 bug and it
would be fix in version 5.0.6. I searched tapestry mailling list, but I
haven't gotten the answer. Does anybody know how to fix it? do your guys
don't meet this problem. Or I should modify the T5.0.5' source code?

Thanks.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



T5 Intermittent NPE

2007-08-26 Thread jason lea
Hi,

We are getting an intermittent NullPointerException in Tapestry 5.0.5.  We
are running on Java 1.5.
It seems that the RequestGlobals has a null Request when the call to
getCookies is made (or that RequestGlobals is null).  We cannot get the
error to occur every time so testing is tricky, sometimes it occurs on the
first request after the webapp starts with subsequent requests good for a
few minutes before it occurs again.  Other times it starts fine and pressing
F5 100 times might make it occur.

Our thought at the moment is that a ThreadLocal bug (
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6550283 ) might be
causing the RequestGlobals to initially be correctly initialised and stored
in ThreadLocal but later on with more items being added this bug means
further down the track, a new RequestGlobals is added with null values.

Anyone have any experience with this error or ideas on how to fix/work
around it?


Here is the stacktrace:

java.lang.NullPointerException
at org.apache.tapestry.internal.services.InternalModule$2.getCookies(
InternalModule.java:294)
at $CookieSource_114a4a153ae.getCookies($CookieSource_114a4a153ae.java)
at org.apache.tapestry.internal.services.CookiesImpl.readCookieValue(
CookiesImpl.java:53)
at $Cookies_114a4a153ad.readCookieValue($Cookies_114a4a153ad.java)
at org.apache.tapestry.services.PersistentLocaleImpl.getCookieValue(
PersistentLocaleImpl.java:46)
at org.apache.tapestry.services.PersistentLocaleImpl.get(
PersistentLocaleImpl.java:40)
at $PersistentLocale_114a4a153ac.get($PersistentLocale_114a4a153ac.java)
at
org.apache.tapestry.internal.services.LocalizationSetterImpl.setThreadLocale
(LocalizationSetterImpl.java:98)
at
$LocalizationSetter_114a4a153a5.setThreadLocale($LocalizationSetter_114a4a153a5.java)
at org.apache.tapestry.internal.services.LocalizationFilter.service(
LocalizationFilter.java:41)
at $RequestHandler_114a4a153ab.service($RequestHandler_114a4a153ab.java)
at org.apache.tapestry.services.TapestryModule$2.service(
TapestryModule.java:657)
at $RequestHandler_114a4a153ab.service($RequestHandler_114a4a153ab.java)
at org.apache.tapestry.internal.services.StaticFilesFilter.service(
StaticFilesFilter.java:63)
at $RequestHandler_114a4a153ab.service($RequestHandler_114a4a153ab.java)
at org.apache.tapestry.internal.services.CheckForUpdatesFilter$2.invoke(
CheckForUpdatesFilter.java:97)
at org.apache.tapestry.internal.services.CheckForUpdatesFilter$2.invoke(
CheckForUpdatesFilter.java:88)
at org.apache.tapestry.ioc.internal.util.ConcurrentBarrier.withRead(
ConcurrentBarrier.java:77)
at org.apache.tapestry.internal.services.CheckForUpdatesFilter.service(
CheckForUpdatesFilter.java:110)
at $RequestHandler_114a4a153ab.service($RequestHandler_114a4a153ab.java)
at $RequestHandler_114a4a1539f.service($RequestHandler_114a4a1539f.java)
at org.apache.tapestry.services.TapestryModule$11.service(
TapestryModule.java:1044)
at
org.apache.tapestry.upload.services.MultipartServletRequestFilter.service(
MultipartServletRequestFilter.java:42)
at
$HttpServletRequestHandler_114a4a153a0.service($HttpServletRequestHandler_114a4a153a0.java)
at
$HttpServletRequestHandler_114a4a1539d.service($HttpServletRequestHandler_114a4a1539d.java)
at org.apache.tapestry.TapestryFilter.doFilter(TapestryFilter.java:135)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:206)
at
org.adscale.client.http.filter.AdvisedHibernateSessionInterceptor.doFilter(
AdvisedHibernateSessionInterceptor.java:49)
at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(
AopUtils.java:304)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint
(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:139)
at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(
TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:161)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(
JdkDynamicAopProxy.java:204)
at $Proxy34.doFilter(Unknown Source)
at org.adscale.client.http.filter.HibernateSessionInterceptor.doFilter(
HibernateSessionInterceptor.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:206)
at org.apache.catalina.core.Stand

Why do setting an unbounded component parameter throws an exception?

2007-08-26 Thread Martino Piccinato
Hi,

I don't understand why ParameterPropertyWorker makes parameter mutator
throw an exception if called over an unbounded parameter. I see this
behaviour as illogic: ParameterPropertyWorker do create a property
field so why not using this field to set the parameter if no binding
is available instead of throwing an exception? As a possible useful
example the field might be changed by a listener and later reused
later on during rendering.

So in my opinion if there's no binding there should be no exception
thrown and obviously  setObject should not be called on the (null)
binding, this would be the correct behaviour.


But maybe it's just my misunderstanding of tapestry logic and there's
a very good reason to throw this exception.

Martino

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5 Retriving the Client IP Address

2007-08-26 Thread Jonathan Glanz

I've tried a few times now and can't seem to add anything to the wiki

it keeps telling me I need to save something to a fileI want to  
post some validators and submodule samples as well as various  
contributions and tricks



any ideas?

On Aug 26, 2007, at 5:37 PM, 小司 wrote:


:-)it's happened to me.

2007/8/24, César Les <[EMAIL PROTECTED]>:

I added this tip to the wiki (Tapestry5ObtainingHttpServletRequest),
because is exactly that happened to me too. :)

Regards

Cesar.

On 8/23/07, Charles Mason <[EMAIL PROTECTED]> wrote:

On 8/23/07, César Les <[EMAIL PROTECTED]> wrote:

may be you need to add the servlet-api.jar to your class path


Thanks for that. It wouldn't compile because servlet-api.jar  
wasn't in

my class path.

The reason I thought it had been removed was because I was using
eclipses auto complete drop down list box to see what methods were
available. For what ever reason Eclipse decides to not to show any
entry at all for methods that use classes it can't find. That will
teach me to rely on Eclipses Auto complete too much.

Thanks all for the help.

Charlie M

 
-

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
得与失都是生活



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5 Retriving the Client IP Address

2007-08-26 Thread 小司
:-)it's happened to me.

2007/8/24, César Les <[EMAIL PROTECTED]>:
> I added this tip to the wiki (Tapestry5ObtainingHttpServletRequest),
> because is exactly that happened to me too. :)
>
> Regards
>
> Cesar.
>
> On 8/23/07, Charles Mason <[EMAIL PROTECTED]> wrote:
> > On 8/23/07, César Les <[EMAIL PROTECTED]> wrote:
> > > may be you need to add the servlet-api.jar to your class path
> >
> > Thanks for that. It wouldn't compile because servlet-api.jar wasn't in
> > my class path.
> >
> > The reason I thought it had been removed was because I was using
> > eclipses auto complete drop down list box to see what methods were
> > available. For what ever reason Eclipse decides to not to show any
> > entry at all for methods that use classes it can't find. That will
> > teach me to rely on Eclipses Auto complete too much.
> >
> > Thanks all for the help.
> >
> > Charlie M
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
得与失都是生活


Re: [T5] Restricting Page Access

2007-08-26 Thread Charles Mason
On 8/24/07, Robin Helgelin <[EMAIL PROTECTED]> wrote:>
> To ask your second question, the code tapestry5-acegi uses to wrap
> around the class is found here in this service:
> 

Thanks for the info. I had been studying the code for a while. I
didn't look at that class much because I assumed from its title it was
dealing with the acegi library work rather than the tapestry side of
things. I should have known better than to assume things from class
names :)

What I want to do is have a SecuredPage annotation, which can be added
to any page class. Then before any page annotated with SecuredPage is
run, it calls a method that decides wither or not to redirect the user
to another page, bassed on there login info from the Application
State.

I have made my own worker class, annotation and service. I understand
the acegi worker class except for the transform page part. I can't
work out how its managing to change the page. Its clearly modifying a
method but, I cant really work out how.

The other thing I was struggling with is, how I actually integrate the
worker in to my service. I have a RequestFilter working from AppModule
which is executed for every request. But how do I use the worker class
I have just created? I could just call the transform method, but where
do I get the ClassTransformation object from. I assume there is some
correct way to apply a ComponentClassTransformWorker to a component>

Any help / suggestions would be really appreciated.

Charlie M

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T5]: Question about temporary properties

2007-08-26 Thread Kevin Menard
On 8/24/07 5:44 PM, in article
[EMAIL PROTECTED], "Josh Canfield"
<[EMAIL PROTECTED]> wrote:

>> anyway?  If the loop can already figure these out, make them read-only
>> properties of the loop.  Then you could reference them like ${loop_id.index}
>> or ${loop_id.value}.
>> 
> That'd be nice in some cases, but there are also times when I want to
> be able to access them through my component class. I like being able
> to separate out my rendering logic from my page so that I could change
> it in one place. For instance, if you want to color rows of a table
> its nice to be able to do something like
> 
> ...
> 
> and let the component decide the row colouring scheme based on the
> rows position. I suppose you could access the Loop component directly
> to ask it it's position when getRowClass() is called. This leaves you
> with a pretty clean template, I suppose potentially at the expense of
> the class file...

Correct.  You have two approaches:

1) Use a conditional component in the template and nothing ever touches your
page class.

2) Still have a getRowClass() in your page class, but rather than call
getSomeIndex(), it'd call getSomeLoop().getIndex().  I'd argue that the
latter is even better because it removes ambiguity.  By restricting the
choice, you don't have arbitrary index properties that can be named
differently on a per class/project/developer basis.  Rather, you have a
uniform approach to accessing that info.  Plus, you keep static analysis
tools happy.

-- 
Kevin



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: configure tomcat to have www prefix

2007-08-26 Thread Jonathan Barker
You're right - it's not Tapestry related.

You need to set up a DNS entry, so that you can resolve www.sitename.
Usually, you would set up a CNAME so that www.somecompany.com points to
realhostname.somecompany.com.

Tomcat by default will accept whatever you call it.

JB

> -Original Message-
> From: Angelo Chen [mailto:[EMAIL PROTECTED]
> Sent: Sunday, August 26, 2007 7:25 AM
> To: users@tapestry.apache.org
> Subject: configure tomcat to have www prefix
> 
> 
> Hi,
> 
> Sorry, this question might not be Tapestry related. I have a site that
> runs
> only tomcat, the url is always http://sitename, is there a possibility to
> configre to have:www.sitename? Thanks.
> 
> A.C.
> --
> View this message in context: http://www.nabble.com/configure-tomcat-to-
> have-www-prefix-tf4330821.html#a12334053
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Can you tell me how to create PDF using Jasperreport on T5?

2007-08-26 Thread Eko S.W.
Hi All,

firstly, I think it is the same as creating Char using Jasperreport, that is
we must build our own Component using JFreeChart ( I read it on Wiki)

But, what about the case of creating PDF using jasperreport?
Can you show how to do it?
Because I rather confuse...

Thanks in advance.
-- 
Best wishes,
Eko SW
http://swdev.blogs.friendster.com/my_blog/


configure tomcat to have www prefix

2007-08-26 Thread Angelo Chen

Hi,

Sorry, this question might not be Tapestry related. I have a site that runs
only tomcat, the url is always http://sitename, is there a possibility to
configre to have:www.sitename? Thanks.

A.C.
-- 
View this message in context: 
http://www.nabble.com/configure-tomcat-to-have-www-prefix-tf4330821.html#a12334053
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T5] Restricting Page Access

2007-08-26 Thread Charles Mason
On 8/25/07, Nick Westgate (Work) <[EMAIL PROTECTED]> wrote:
>
> Also, just as a reminder, base classes must not go in the pages package.
>

I thinks that's where my RistrictedPage class was going wrong. I think
I will play around with trying to create some tapestry5-acegi like
annotations and request filters.

ACEGI I think is a bit more than I need. However I use the same base
login / user management package I created for a few sites, so I think
it would pay to get the restricting of pages right for all the new
Tapestry 5 versions. Plus its a good exercise in learning some of the
more complicated bits of Tapestry 5.

Thanks for all, the help.

Charlie M

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5 on JDK 1.6 or newer

2007-08-26 Thread Tom Davies


On 25/08/2007, at 3:01 AM, Stephan Schwab wrote:



We've been experiencing strange behaviour of our now growing  
application
Savila and as well with another project we are working on. Both use  
Tapestry
5.0.5. Our development machines run with Mac OS X and we use JDK  
1.5 that
comes with it. We deploy to Linux with Sun's JDK 1.6 and Tomcat  
6.0.10.


Our application Savila ran fine on JDK 1.6 with Tapestry 5.x until  
last week

when we started to experience hangs. It seems that Tomcat accepts the
request, then our and Tapestry's code do something, but it never  
finishes.


What does a thread dump show?

Tom

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]