You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Miguel Galves <mg...@gmail.com> on 2006/05/25 20:46:42 UTC
Custom RequestProcessor
Hi,
I wrote a new controller class, which extends TileRequestProcessor, in order
to solve a problem we had with POST requests enconding (UTF-8), specially
with multipart-form requests.
I'm now trying to pass some paremeters to the new controller, using
the set-property tag in server.xml
<controller
processorClass="utilities.MyTilesRequestProcessor"
contentType="text/html; charset=UTF-8">
<set-property property="teste" value="hellworld"/>
</controller>
but its not working. I've created a setTeste method in my processor, as
showed above
public class ScyllaTilesRequestProcessor extends TilesRequestProcessor {
public String teste;
public void process(HttpServletRequest request, HttpServletResponse
response) throws IOException,
ServletException {
...
}
public void setTeste(String value){
System.out.println("PASSEI POR AQUI: "+value);
}
public void getTeste(){
System.out.println("PASSEI POR AQUI: ");
}
}
but I'm still geeting the following exception:
May 25, 2006 9:07:12 AM org.apache.commons.digester.Digester startElement
SEVERE: Begin event threw exception
java.lang.NoSuchMethodException: Bean has no property named teste
at org.apache.commons.digester.SetPropertyRule.begin(
SetPropertyRule.java:144)
at org.apache.commons.digester.Rule.begin (Rule.java:152)
at org.apache.commons.digester.Digester.startElement(Digester.java:1286)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(
AbstractSAXParser.java:533)
at
com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(
AbstractXMLDocumentParser.java:220)
at
com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(
XMLDTDValidator.java:819)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(
XMLNSDocumentScannerImpl.java:316)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch
(XMLDocumentFragmentScannerImpl.java:1693)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(
XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(
XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse (
XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(
XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(
AbstractSAXParser.java:1242)
at org.apache.commons.digester.Digester.parse(Digester.java:1572)
at org.apache.struts.action.ActionServlet.parseModuleConfigFile(
ActionServlet.java:738)
at org.apache.struts.action.ActionServlet.initModuleConfig (
ActionServlet.java:687)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:333)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet (
StandardWrapper.java:1091)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java
:925)
at org.apache.catalina.core.StandardContext.loadOnStartup(
StandardContext.java:3857)
at org.apache.catalina.core.StandardContext.start (StandardContext.java
:4118)
at org.apache.catalina.core.ContainerBase.addChildInternal(
ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java
:739)
at org.apache.catalina.core.StandardHost.addChild (StandardHost.java
:524)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:788)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java
:498)
at org.apache.catalina.startup.HostConfig.check (HostConfig.java:1179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (
DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java
:503)
at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke (
DynamicMetaDataImpl.java:213)
at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:220)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(
DefaultMBeanServerInterceptor.java:815)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java
:784)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java
:1377)
at org.apache.catalina.manager.ManagerServlet.deploy (
ManagerServlet.java:636)
at org.apache.catalina.manager.ManagerServlet.doPut(ManagerServlet.java
:423)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:712)
at javax.servlet.http.HttpServlet.service (HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java :173)
at org.apache.catalina.core.StandardWrapperValve.invoke(
StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(
StandardContextValve.java:178)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke (
AuthenticatorBase.java:482)
at org.apache.catalina.core.StandardHostValve.invoke(
StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(
ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke (
StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(
CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:856)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(
Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(
LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
I just can't find any documentation about how to configure the processor
properly.
Do I have to write a custom ModuleConfig with my parameters ?
Can somebody help me ?
--
Miguel Galves - Engenheiro de Computação
Já leu meus blogs hoje?
Para geeks http://log4dev.blogspot.com
Pra pessoas normais
http://miguelgalves.blogspot.com
"Não sabendo que era impossível, ele foi lá e fez..."
Re: Custom RequestProcessor
Posted by Miguel Galves <mg...@gmail.com>.
Niall,
the className parameter its just what I was looking for. I think the name
could
be a little more intuitive, like configClassName, or something like that.
Now its working.
Thanks for your help.
Regards,
Miguel
On 5/25/06, Niall Pemberton <ni...@gmail.com> wrote:
>
> On 5/25/06, Miguel Galves <mg...@gmail.com> wrote:
> > Hi,
> >
> > I wrote a new controller class, which extends TileRequestProcessor, in
> order
> > to solve a problem we had with POST requests enconding (UTF-8),
> specially
> > with multipart-form requests.
> >
> > I'm now trying to pass some paremeters to the new controller, using
> > the set-property tag in server.xml
> >
> > <controller
> > processorClass="utilities.MyTilesRequestProcessor"
> > contentType="text/html; charset=UTF-8">
> > <set-property property="teste" value="hellworld"/>
> > </controller>
> >
> > but its not working. I've created a setTeste method in my processor, as
> > showed above
>
> As a rule in general <set-property> doesn't work on the actual object
> being instantiated - but on the config object for that class. So for
> example using <set-property> for an <action> element sets a property
> on the ActionConfig and not the Action class. So you would add the
> property to ActionConfig and configure Struts to use a custom
> ActionConfig implementation.
>
> I haven't actually tried to do what you want but what you should be
> trying to do is specifying a custom ControllerConfig implementation
> with that property on. You can then access that property in the
> RequestProcessor thru' the ModuleConfig:
>
> MyControllerConfig controller =
> (MyControllerConfig)moduleConfig.getControllerConfig().
> String teste = controller.getTeste()
>
> In your struts config you specify the ControllerConfig implementation
> using the className:
>
> <controller
> className="utilities.MyControllerConfig"
> processorClass="utilities.MyTilesRequestProcessor"
> contentType="text/html; charset=UTF-8">
> <set-property property="teste" value="hellworld"/>
> </controller>
>
> Niall
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>
--
Miguel Galves - Engenheiro de Computação
Já leu meus blogs hoje?
Para geeks http://log4dev.blogspot.com
Pra pessoas normais
http://miguelgalves.blogspot.com
"Não sabendo que era impossível, ele foi lá e fez..."
Re: Custom RequestProcessor
Posted by Niall Pemberton <ni...@gmail.com>.
On 5/25/06, Miguel Galves <mg...@gmail.com> wrote:
> Hi,
>
> I wrote a new controller class, which extends TileRequestProcessor, in order
> to solve a problem we had with POST requests enconding (UTF-8), specially
> with multipart-form requests.
>
> I'm now trying to pass some paremeters to the new controller, using
> the set-property tag in server.xml
>
> <controller
> processorClass="utilities.MyTilesRequestProcessor"
> contentType="text/html; charset=UTF-8">
> <set-property property="teste" value="hellworld"/>
> </controller>
>
> but its not working. I've created a setTeste method in my processor, as
> showed above
As a rule in general <set-property> doesn't work on the actual object
being instantiated - but on the config object for that class. So for
example using <set-property> for an <action> element sets a property
on the ActionConfig and not the Action class. So you would add the
property to ActionConfig and configure Struts to use a custom
ActionConfig implementation.
I haven't actually tried to do what you want but what you should be
trying to do is specifying a custom ControllerConfig implementation
with that property on. You can then access that property in the
RequestProcessor thru' the ModuleConfig:
MyControllerConfig controller =
(MyControllerConfig)moduleConfig.getControllerConfig().
String teste = controller.getTeste()
In your struts config you specify the ControllerConfig implementation
using the className:
<controller
className="utilities.MyControllerConfig"
processorClass="utilities.MyTilesRequestProcessor"
contentType="text/html; charset=UTF-8">
<set-property property="teste" value="hellworld"/>
</controller>
Niall
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org