T5: contributeValueEncoderSource

2008-08-09 Thread Ned Jackson Lovely
I'm using tapestry-hibernate, and I'm enjoying all the magic that it
provides, but I'm having one issue.

I'd like to provide my own ValueEncoderSources for my mapped entities.
I need to do some security checks and other housekeeping as I load
them.

Unfortunately, when I attempt to do something like this:

public static void
contributeValueEncoderSource(MappedConfiguration configuration, final ThingDao dao) {
configuration.add(Thing.class, new ThingValueEncoderFactory());
}

I get the following warning:

[WARN] TapestryModule.ValueEncoderSource Service contribution (to
service 'ValueEncoderSource', by
njl.webapp.services.AppModule.contributeValueEncoderSource(MappedConfiguration,
ThingDao) (at AppModule.java:76)) conflicts with existing contribution
(by 
org.apache.tapestry5.hibernate.HibernateModule.contributeValueEncoderSource(MappedConfiguration,
HibernateSessionSource, Session, TypeCoercer, PropertyAccess,
LoggerSource) (at HibernateModule.java:149)) and has been ignored.

I realize I'm running up against the work done by the
contributeValueEncoderSource function in
org.apache.tapestry5.hibernate.HibernateModule

Is there a simple way to override this, or do I have to do something ugly?

-- 
njl

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



Re: T5 onActivate

2008-06-10 Thread Ned Jackson Lovely
On Sun, Jun 8, 2008 at 5:00 AM, maxthesecond <[EMAIL PROTECTED]> wrote:
> As for loggin the request-filter option is very attractive, all that crap in
> just one place.

I've been wondering about the request filter... To determine which
page is being accessed, I've been parsing the path myself, using code
I cut and pasted out of tapestry internals. I got this method from
http://wiki.apache.org/tapestry/Tapestry5HowToControlAccess, which
incidentally doesn't work with
the past couple of releases.

My issue is, I feel like this is a potential security problem. If
Tapestry changes how it parses the path, an attacked could conceivably
create a request that I think is for one page in my security
dispatcher, while it is really for another. Is there a service I can
inject to get the page that Tapestry has parsed out?

-- 
njl

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



Re: Little confused

2008-05-17 Thread Ned Jackson Lovely
Set your private variable to null in your onSuccess function.

On 5/17/08, Manuel Corrales <[EMAIL PROTECTED]> wrote:
> Thanks for your answer, but i still have the same issue. Maybe i am not
> explaining the problem ok. I have a page with a link, when i press the link
> the application goes to the new Matafuego page, where i am using a "hand
> made form" (i mean not using beaneditorform tag). The first time i do this,
> everything works fine, i complete the date press Save and the application
> redirects to the main page again. But the second time i press the link to
> add a new Matafuego, the form has the data i complete on the first one. The
> behavior i am looking here, is that each time i access the form, i create a
> new Matafuego, i mean a clean form and a new Matafuego instance.
>
> Thanks in advance.
>
> On Sat, May 17, 2008 at 11:54 AM, Kevin Menard <[EMAIL PROTECTED]>
> wrote:
>
>> I would probably use a lazy getter with a @Persist attached to the field.
>>
>> Something like:
>>
>> @Persist
>> private Matafuego matafuego;
>>
>> public Metafuego getMetafuego()
>> {
>>   if (null == metafuego)
>>   {
>>   metafuego = new Metafuego();
>>   }
>>
>>   return metafuego;
>> }
>>
>> The page instance is guaranteed to be accessed by only a single thread at
>> a
>> time, so that should be safe for you.
>>
>> --
>> Kevin
>>
>>
>> On 5/17/08 10:01 AM, "Manuel Corrales" <[EMAIL PROTECTED]> wrote:
>>
>> > Hi, here is my problem. I have a bean on my java page, but i am not
>> > using
>> > the beaneditorform component to create a new one. Acording to Alexander
>> > book, the beaneditorform component can handle the initialization of the
>> > bean, so you dont have to create one. As i am not using this component,
>> > should i define the bean with a sentence like this:
>> >
>> > private Matafuego matafuego = new Matafuego();
>> >
>> > or should i create the new instance on the onActivate method?
>> >
>> > I tryied the first approach, but the bean is always the same (i guess
>> > because of the page pooling mechanism). What is the right approach to
>> this?
>> >
>> > Thanks very much.
>>
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>


-- 
njl

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



Re: [T5]

2007-10-01 Thread Ned Jackson Lovely
On Mon, Oct 01, 2007 at 10:56:56AM -0500, Robert Zeigler wrote:
> Or...
> 
> @Inject
> private Cookies _cookies;
> 
> You can then do:
> 
> readCookieValue("mycookie");
> and there a variety of "writeCookieValue" methods offering control  
> over the age, domain, path, etc.

Excellent! Thank you. I need to poke around in the source more, eh?

Unfortunately, I found this:
https://issues.apache.org/jira/browse/TAPESTRY-1796

-- 
njl

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



Re: [T5]

2007-10-01 Thread Ned Jackson Lovely
On Mon, Oct 01, 2007 at 05:00:30PM +0200, Borut BolĨina wrote:
> is there a T5 way of sending and receiving cookies?

@Inject
private RequestGlobals _requestGlobals;

You can then call _requestGlobals.getHTTPServletRequest() and
_requestGlobals.getHTTPServletResponse() to get access to the Servlet
Request and Response.

-- 
njl

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



Re: T5: Editing a db persisted object with BeanEditForm

2007-09-01 Thread Ned Jackson Lovely
On Fri, Aug 31, 2007 at 06:24:58PM +0300, Imants Firsts wrote:
> How do I correctly set up a BeanEditForm for editing a
> hibernate entity?

I don't think I'm even close to writing idiomatic Tapestry 5 (if such a
thing even exists), but here is the pattern I've been using:

EditMyBean.java
---
public class EditMyBean {

@ApplicationState
private MyDBClass _theBean;

public MyDBClass getTheBean(){return _theBean;}

public void onActivate(long id){
_theBean = getDAO().getById(id);
}
public long onPassivate(){
return _theBean.getId();
}

@Component(id = "beanEditForm")
private BeanEditForm _beanEditForm;


public void onValidate(){
//Validate the changes. Add errors to the form using
//_beanEditForm.recordError(String). This will automagically
//cause the page to redisplay.
}

public void onSuccess(){
getDAO().saveOrUpdate(_theBean);
}
}
---

EditMyBean.html
---
http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
EditMyBean












---


-- 
njl

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



Re: [T5] Usage of Grid component

2007-08-31 Thread Ned Jackson Lovely
On Thu, Aug 30, 2007 at 08:06:54AM +0200, Christoph Jaeger wrote:
> A comma separated list of properties would be great. Then you can hide
> and sort columns as you like (didn't think about sorting yet).

http://blog.njl.us/blojsom/blog/default/2007/09/01/Configurable-Grid

-- 
njl

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



Re: [T5] How to add a extra column for delete/update action using Grid component.

2007-08-21 Thread Ned Jackson Lovely
On Tue, Aug 21, 2007 at 10:21:32PM +0800, Allen Guo wrote:
> Usually we display user list using grid component. It's like this
>  pagerPosition="both">
> 
> 
> As shown above, the source property value is 'users' is just the user
> list may fetch from database.
> The result will display all properties of user class in table .
> Now I want to only display some of properties of user class and add some
> extra columns like delete/update action to each row.
> What should I do?

To add a column, you need to create a BeanModel. 

@Inject
@Service(value = "BeanModelSource")
private BeanModelSource _beanModelSource;

@Inject
@Service(value = "ComponentResources")
private ComponentResources _componentResources;

private BeanModel _model;

public BeanModel getModel(){return _model;}


public void onActivate(){
_model = _beanModelSource.create(YOUR_OBJECT_HERE.class, true, 
_componentResources);

_model.add("action", new NullPropertyConduit()).order(-1)
.sortable(false);

//You /should/ use the @NonVisual action to hide properties you
//generally don't want displayed. On the other hand, you can
//remove properties from the BeanModel here.
}

//Other stuff elided.
-

I have a NullPropertyConduit object that is nothing but generic responses
to all of the function calls in the PropertyConduit interface. That doesn't
matter, because instead of worrying about what the conduit is going to
pull from my bean, I provide it with a template that contains this:

-


Delete


-

This isn't a drop-in and have it work example, but I think all the fundamental
things you need to do to get the find of functionality you want are 
illustrated. Good luck!

-- 
njl

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



Re: T5 tapestry-spring: have to interface all HibernateDaoSupport methods

2007-06-25 Thread Ned Jackson Lovely
On Mon, Jun 25, 2007 at 06:02:16PM -0500, Bill Holloway wrote:
> I have the following DAO pattern:
> 
> public class FooDaoImpl
>   extends HibernateDaoSupport
>   implements FooDao
> {
>   // some custom Foo dao methods.
> }
> 
> However, tapestry-ioc spring bean injection injects via interface.
> So, none of the HibernateDaoSupport or HibernateTemplate methods like
> saveOrUpdate or merge or get are visible from my injected DAO unless
> they're explicitly written into the FooDao interface or some higher
> level interface that FooDao extends.  Pain.

Unless I misunderstand you, you need to do the following:

In your code:
--
@Inject
@Service("fooDao")
private FooDao _fooDao;
--

In your spring context file:
--



--

-- 
njl

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