You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by George Christman <gc...@cardaddy.com> on 2012/08/29 21:59:32 UTC

Passing form component into service

Hello, I'm wondering if someone could tell me if it's possible to pass the
form component into my validation service to record form errors. I'm getting
the following exception. 

java.lang.LinkageError
loader constraint violation: when resolving interface method
"org.company.eprs.services.PurchaseRequestValidationService.validate(Lorg/apache/tapestry5/corelib/components/Form;)V"
the class loader (instance of
org/apache/tapestry5/internal/plastic/PlasticClassLoader) of the current
class, org/company/eprs/pages/Purchase_Request, and the class loader
(instance of org/mortbay/jetty/webapp/WebAppClassLoader) for resolved class,
org/company/eprs/services/PurchaseRequestValidationService, have different
Class objects for the type org/apache/tapestry5/corelib/components/Form used
in the signature

Code used

MyClass

    @Component(id = "PR")
    private Form form;

    @Inject
    private PurchaseRequestValidation purchaseRequestValidation;

void onValidateFromPR() throws Exception {       
    this.purchaseRequestValidation.validate(this.form);
}

MyService 

public void validate(Form form) {
 //do something
}

Thanks



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Passing-form-component-into-service-tp5715894.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Passing form component into service

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 30 Aug 2012 10:33:45 -0300, George Christman  
<gc...@cardaddy.com> wrote:

> Thanks Lance, management asked me to put all my validation's in a  
> service, however I figured there would be an issue passing the tapestry  
> form
> component into the service. I think the domain object would be the best
> option although I don't see any cost benefit in this extra layer of
> abstraction.

You have absolutely nothing you can do with the Form component instance  
itself passed to a service, as you can't pull the values to be validated  
 from it. You need to pass the service the object(s) being edited, as you  
said. On the other hand, you may pass the ValidationTracker so you can  
register errors in it directly.

-- 
Thiago H. de Paula Figueiredo

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


Re: Passing form component into service

Posted by George Christman <gc...@cardaddy.com>.
Thanks Guys for the alternate suggestions. I'll keep them in mind when I run
into this again. For now the app is just to small to make it worth it. 



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Passing-form-component-into-service-tp5715894p5715910.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Passing form component into service

Posted by Lance Java <la...@googlemail.com>.
The Form component implements FormValidationControl. If this interface
provides what you need, there is no need for a domain object.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Passing-form-component-into-service-tp5715894p5715909.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Passing form component into service

Posted by George Christman <gc...@cardaddy.com>.
Thanks Lance, management asked me to put all my validation's in a service,
however I figured there would be an issue passing the tapestry form
component into the service. I think the domain object would be the best
option although I don't see any cost benefit in this extra layer of
abstraction. 



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Passing-form-component-into-service-tp5715894p5715907.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Passing form component into service

Posted by Lance Java <la...@googlemail.com>.
No, this is not allowed and is generally considered bad practice. You will
need to pass a class (or interface) that is not in the
components/pages/mixins/base packages.

There are two main options:
1. Copy the data into a domain object and pass the domain object
2. Have your component implement an interface and pass by interface instead
of the concrete component type.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Passing-form-component-into-service-tp5715894p5715896.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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