cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gabriel Gruber <Gabriel.Gru...@workflow.at>
Subject Re: Integration of Wicket Servlet within C2.2 Block with servlet service -> Problem
Date Thu, 11 Oct 2007 19:13:24 GMT
thanx all for your great help. 

I am getting closer...

I adjusted the init code of the wicketapplication class as suggested and 
wired the wicket-servlet into the block2-sitemap:

  <bean id="com.mycompany.block2.service" class=
"org.apache.cocoon.sitemap.SitemapServlet">
    <servlet:context mount-path="/block2" context-path=
"blockcontext:/block2/">
      <servlet:connections>
        <entry key="wicketservlet" value-ref=
"com.mycompany.block2.wicketapp"></entry>
      </servlet:connections>
    </servlet:context>
 
  </bean>
 
  <bean id="com.mycompany.block2.wicketapp" class=
"org.apache.wicket.protocol.http.WicketServlet">
    <servlet:context mount-path="/block2-wicket" context-path=
"blockcontext:/block2/">
      <servlet:init-params>
        <entry key="applicationClassName">
          <value>com.mycompany.WicketApplication</value>
        </entry>
      </servlet:init-params>
 
    </servlet:context>
  </bean>

sitemap:

      <map:match pattern="wicket">
        <map:generate src="servlet:wicketservlet:/"/>
        <map:serialize type="html"/>
      </map:match>


however, now i get a NPE:
Caused by: java.lang.NullPointerException
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:702)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at 
org.apache.cocoon.servletservice.ServletServiceContext$PathDispatcher
.forward(ServletServiceContext.java:537)
        at 
org.apache.cocoon.servletservice.ServletServiceContext$NamedDispatche
r.forward(ServletServiceContext.java:480)
        at 
org.apache.cocoon.servletservice.ServletConnection.connect(ServletCon
nection.java:124)
        at 
org.apache.cocoon.servletservice.components.ServletSource.connect(Ser
vletSource.java:159)
        at 
org.apache.cocoon.servletservice.components.ServletSource.getInputStr
eam(ServletSource.java:79)
        at 
org.apache.cocoon.components.source.util.SourceUtil.getInputSource(So
urceUtil.java:395)
        at 
org.apache.cocoon.components.source.util.SourceUtil.parse(SourceUtil.
java:238)
        at 
org.apache.cocoon.generation.FileGenerator.generate(FileGenerator.jav
a:109)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at 
org.apache.cocoon.core.container.spring.avalon.PoolableProxyHandler.i
nvoke(PoolableProxyHandler.java:61)
        at $Proxy4.generate(Unknown Source)
        at 
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.proc
essXMLPipeline(AbstractProcessingPipeline.java:542)
        ... 58 more

any ideas?

Gabriel

______________________
Mag. Gabriel Gruber
Senior Consultant
http://www.workflow.at





Mats <mats@alma.nu> 
11.10.2007 19:52
Please respond to
dev@cocoon.apache.org


To
dev@cocoon.apache.org
cc

Subject
Re: Integration of Wicket Servlet within C2.2 Block with servlet service 
-> Problem






Given the java code and the output I would say that Daniel is correct.
In the init-method of your Application-class you could do:

  protected void init() {
         super.init();
         getMarkupSettings().setStripWicketTags(true);
  }

This will remove the wicket:id attributes from the rendered output.

/Mats


Daniel Fagerstrom skrev:
> I don't have much knowledge about Wicket. But AFAICS you got the output 
> that I would expect: The Label instruction in the Java code sets the 
> content of the span and the TextArea and Buton instructions doesn't give 

> any visible results, but are probably added to your server side model, 
> ready to take care of post data.
> 
> What output would you expect?
> 
> /Daniel
> 
> Gabriel Gruber skrev:
>>
>> hmm, thanx Daniel that helped.
>>
>> the url-context correctly redirects to the wicket-servlet. however it 
>> seems the xhtml wicket tags are not beeing rendered correctly by the 
>> wicket servlet.
>>
>> the returned output is:
>> <?xml version='1.0' encoding='UTF-8'?>
>> <xhtml>
>>     <head>
>>         <title>Wicket Quickstart Archetype Homepage</title>
>>     </head>
>>     <body>
>>         <strong>Wicket Quickstart Archetype Homepage</strong>
>>         <br/><br/>
>>         <span wicket:id="message">If you see this message wicket is 
>> properly configured and running</span>
>>         <br/><br/>
>>         Input field:<br/>
>>         <textarea wicket:id="yourinput" name="yourinput"></textarea>
>>         <br/>
>>         <button wicket:id="PressMe" name="PressMe" 
>> id="PressMe1">Wegschicken</button>
>>     </body>
>> </xhtml>
>>
>> which is actually the unmodified homepage.xml
>>
>> my wicketpage.java looks like this:
>>
>> import org.apache.wicket.PageParameters;
>> import org.apache.wicket.markup.html.basic.Label;
>> import org.apache.wicket.markup.html.form.Button;
>> import org.apache.wicket.markup.html.form.TextArea;
>> import org.apache.wicket.markup.html.WebPage;
>>
>> /**
>>  * Homepage
>>  */
>> public class HomePage extends WebPage {
>>
>>         private static final long serialVersionUID = 1L;
>>
>>         // TODO Add any page properties or variables here
>>
>>     /**
>>          * Constructor that is invoked when page is invoked without a 
>> session.
>>          *
>>          * @param parameters
>>          *            Page parameters
>>          */
>>     public HomePage(final PageParameters parameters) {
>>
>>         // Add the simplest type of label
>>         add(new Label("message", "If you see this message wicket is 
>> properly configured and running"));
>>
>>                // TODO Add your page's components here
>>         add(new TextArea("yourinput"));
>>         add(new Button("PressMe"));
>>     }
>>        public String getMarkupType() {
>>             return "xml";
>>     }
>> }
>>
>> any ideas?  I recall some guys at the cocoon GT wanted to showcase a 
>> Wicket integration...
>>
>> thanx in advance..
>>
>> gabriel
>>
>> ______________________
>> Mag. Gabriel Gruber
>> Senior Consultant
>> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>> Workflow EDV GmbH, Dannebergplatz 6/23, A-1030 Wien
>> mailto:gabriel.gruber@workflow.at
>> http://www.workflow.at
>>
>>
>> *Daniel Fagerstrom <danielf@nada.kth.se>*
>>
>> 11.10.2007 18:13
>> Please respond to
>> dev@cocoon.apache.org
>>
>>
>> 
>> To
>>     dev@cocoon.apache.org
>> cc
>> 
>> Subject
>>     Re: Integration of Wicket Servlet within C2.2 Block with servlet 
>> service -> Problem
>>
>>
>> 
>>
>>
>>
>>
>>
>> Gabriel Gruber skrev:
>>  >
>>  > Dear C2.2 Dev-Community!
>>  >
>>  > I just played around with Wicket and wanted to integrate a 
HelloWorld
>>  > Wicket application within a C2.2 Block as a servlet service:
>>  >
>>  > <beans xmlns="http://www.springframework.org/schema/beans"
>>  >   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>  >   xmlns:servlet="http://cocoon.apache.org/schema/servlet"
>>  >   xsi:schemaLocation="http://www.springframework.org/schema/beans
>>  > http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
>>  >   http://cocoon.apache.org/schema/servlet
>>  > http://cocoon.apache.org/schema/servlet/cocoon-servlet-1.0.xsd">
>>  >   >   <bean id="com.mycompany.block2.service"
>>  > class="org.apache.cocoon.sitemap.SitemapServlet">
>>  >     <servlet:context mount-path="/block2"
>>  > context-path="blockcontext:/block2/"/>
>>  >   </bean>
>>  >   >   <bean id="com.mycompany.block2.wicketapp"
>>  > class="org.apache.wicket.protocol.http.WicketServlet">
>>  >     <servlet:init-params>
>>  >       <entry key="applicationClassName">
>>  >         <value>com.mycompany.WicketApplication</value>
>>  >       </entry>
>>  >     </servlet:init-params>
>>  >     <servlet:context mount-path="/block2-wicket"
>>  > context-path="blockcontext:/block2-wicket/"/>
>>  >   </bean>
>>  >   > </beans>
>>  >
>>  > While this seems generally ok, there seems to be a problem with the
>>  > spring namespacehandler for the servlet service tags. When i start
>>  > spring an exception is thrown like this...
>>  > Caused by:
>>  > org.springframework.beans.factory.BeanDefinitionStoreException: 
Unable
>>  > to read spring configurations from 
classpath*:META-INF/cocoon/spring;
>>  > nested exception is
>>  > 
>> 
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
>>  > *Configuration problem: Cannot locate BeanDefinitionDecorator for
>>  > element [init-params]*
>>
>> ...
>>  > What is wrong here?
>>  >
>>  > Any suggestions?
>> The servlet:context element must be the root element of the elements in
>> the servlet: namespace. The error message basically sys that there is 
no
>> handler for the servlet:init-params as a  root element.
>>
>> Modify the above  bean definition to:
>>
>>  <bean id="com.mycompany.block2.wicketapp"
>> class="org.apache.wicket.protocol.http.WicketServlet">
>>    <servlet:context mount-path="/block2-wicket"
>> context-path="blockcontext:/block2-wicket/">
>>      <servlet:init-params>
>>        <entry key="applicationClassName">
>>          <value>com.mycompany.WicketApplication</value>
>>        </entry>
>>      </servlet:init-params>
>>    </servlet:context>
>>  </bean>
>>
>> And see if it works.
>>
>> /Daniel
>>
>>
> 



Mime
View raw message