You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Robin Ericsson <lo...@gmail.com> on 2006/11/11 11:57:44 UTC

object injection and class cast

Hi,

This is really a hivemind question, but it's my tapestry usage that
probably is wrong :)

My service looks like this:
    <service-point id="FormProcessingFilter" interface="javax.servlet.Filter">
        <invoke-factory>
            <construct
class="nu.localhost.bwatch.filters.FormProcessingFilter"
initialize-method="afterPropertiesSet">
            	<set property="authenticationFailureUrl"
value="/LoginFailed.html" />
            	<set property="defaultTargetUrl" value="/app" />
            	<set property="filterProcessesUrl"
value="/j_acegi_security_check" />
            </construct>
        </invoke-factory>
    </service-point>

I inject it in tapestry like this:
	@InjectObject("service:bwatch.FormProcessingFilter")
	public abstract Filter getProcessingFilter();

But when I cast it to my class which I know it is, I get a ClassCastException.
FormProcessingFilter filter = (FormProcessingFilter) getProcessingFilter();

What am I doing wrong and how should I solve it? :)

-- 
        regards,
        Robin

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


Multiple 'hidden' fields for the same "for" loop

Posted by Ryan Cuprak <rc...@mac.com>.
Hello,
 Just was curious if the multiple entries for 'prompts' was a cause for concern? 'prompts' is the id of a For loop. I am puzzled why it would appear twice.
 I am using Tapestry 4.1 downloaded October 15th or so. 

 Thanks,
 -Ryan


   <form method="post" action="/survey/direct.svc" id="form">

<div style="display:none;" id="formhidden"><input type="hidden" name="formids" value="prompts,question,question_0"/>
<input type="hidden" name="component" value="form"/>
<input type="hidden" name="page" value="survey"/>
<input type="hidden" name="session" value="T"/>
<input type="hidden" name="submitmode" value=""/>
<input type="hidden" name="submitname" value=""/>
<input type="hidden" name="prompts" value="VZH4sIAAAAAAAAAFvzloG1uIhBJb8oXS85P780XS8LiHPzU1Jz9NyKUlPd8otyA0tTi0sy8/MkSqtXLJh8U5OJgaGiiEEGmxaY0ndXeLlULO12MzEw+TBwxhdChUsYhHyyEssS9XMS89L1g0uKMvPSrX0YuOEKPF1KGISRlHjmlaSmpxZZVxSUMKgF5KQmFqcqpKQWJxdlJqUqVOaXFimkpabmAE0pVsjPU3AqLc7QA/pGEGSAHsgAPagBQo8WLPne2G7BxMDoycBalphTmgr0ggBCnV9pblJqUduaqbLcUx50g3xYwMDAwAgAKt5FqB8BAAA="/>
<input type="hidden" name="prompts" value="VZH4sIAAAAAAAAAG2QP08CMRiHXw4wCpggbEYSBhMTh2PVYDRGJDlzmBgHR1KPN0fxuJ5tDw4HExaNccXBwcTBkW/gB3A3xjAaJxddHFztAf4ZGNrh16e/9nn77xAXHJYZt3WLMd/WG2o1WQ0dveI7knoObtUZtXDPRyEpc597/cFO+WigQcSE6ao1PBQS0maDtEjBl9QpmFTIYsBhYVLtT9HH02xicXX9XgPNhJnq8TiWkBk1OcS1C/uSU9cumpD8BYyShOw/xHAl2siLgafygzqRSyLfYT7P2+jWkG8ovbmQ1kNaH9OZ19u7r+75irIwIN4ijo/qv+k/btdvHiI/61/lkr2XSw0g8ABAU2XZIRR66puck04oG3Qfc9cP5CYa1sUEPcER3o6pPaEuzU+axGiw7YtUa3vt7VPNwVCaHIXHXIFGyYRUtYbC4tQLvY/hFKLD2oiEWIU4KMIoFb4jYaqMTRUF30y8K0nRAQAA"/>
</div>

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


Re: object injection and class cast

Posted by James Carman <ja...@carmanconsulting.com>.
The object you get is actually a proxy to the actual service
implementation.  The dynamic proxy only knows that it needs to support
the javax.servlet.Filter interface, so that's all it supports.  You
can't downcast it to the implementation class.  What you can do is
come up with your own service interface which extends
javax.servlet.Filter and your implementation class can implement that.
 You'd have to use that interface to "talk to" your service object.

p.s. Alternatively, there is such a thing as bean services (the
service interface is the bean class), but I don't suggest using them.
It's better to front your services with an interface (which is what we
have to fabricate at runtime via Javassist to support bean services).


On 11/11/06, Robin Ericsson <lo...@gmail.com> wrote:
> Hi,
>
> This is really a hivemind question, but it's my tapestry usage that
> probably is wrong :)
>
> My service looks like this:
>     <service-point id="FormProcessingFilter" interface="javax.servlet.Filter">
>         <invoke-factory>
>             <construct
> class="nu.localhost.bwatch.filters.FormProcessingFilter"
> initialize-method="afterPropertiesSet">
>                 <set property="authenticationFailureUrl"
> value="/LoginFailed.html" />
>                 <set property="defaultTargetUrl" value="/app" />
>                 <set property="filterProcessesUrl"
> value="/j_acegi_security_check" />
>             </construct>
>         </invoke-factory>
>     </service-point>
>
> I inject it in tapestry like this:
>         @InjectObject("service:bwatch.FormProcessingFilter")
>         public abstract Filter getProcessingFilter();
>
> But when I cast it to my class which I know it is, I get a ClassCastException.
> FormProcessingFilter filter = (FormProcessingFilter) getProcessingFilter();
>
> What am I doing wrong and how should I solve it? :)
>
> --
>         regards,
>         Robin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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