Hi Frédéric,
I saw your series of article at http://www.espacedefouille.org/, thanks for
your interest in OFBiz!
Frédéric Bouquet wrote:
Hi,
Thank you, you point the problem. I did not have the Control Servlet. I
added it and now it works well. I had the mainDecorator section but not the
filter associated and I was getting a NPE from the VisitHandler.
For my information, what does this control servlet do ? And what's the
difference between the mainDecorator and the view-map (name=main) I declare
in controller.xml ? (In fact, if you know which doc I can read about it).
what does this control servlet do
As Javadoc says : <<ControlServlet.java - Master servlet for the web
application.>>
Unfortunately http://ci.apache.org/projects/ofbiz/site/javadocs/ (link from
site main page) is currently unvailable (or rather very
slow) but you can look
at the source into ControlServlet.java, then you may have a look into
RequestHandler class which does most of controller reltated
stuff.
mainDecorator
See <screen name="main-decorator">.
It's one of the decorators used in screen widgets to decorate (using the
decorator pattern
concept) screens defined in *screens*.xml files. Especially it's one of the
most importants, reused by others. Look into any
CommonScreens.xml file for specific details
view-map (name=main)
See <request-map uri="main">
It refers to a view-map like
<view-map name="main" type="screen"
page="component://accounting/widget/CommonScreens.xml#main"/>
in almost all controller, it's unrelated to mainDecorator , just a page to go
I think we can improve the tutorial by adding a few words on this.
Please feel free :o) We will then review...
Jacques
Cheers
2012/8/14 Leonard Lin <[email protected]>
How does your web.xml look like?
You need there an entry for the Control Servlet mounted at "/control/*"
----start-----
<servlet>
<servlet-name>ControlServlet</**servlet-name>
<display-name>ControlServlet</**display-name>
<description>Main Control Servlet</description>
<servlet-class>org.ofbiz.**webapp.control.ControlServlet<**/servlet-class>
<load-on-startup>1</load-on-**startup>
</servlet>
<servlet-mapping>
<servlet-name>ControlServlet</**servlet-name>
<url-pattern>/control/*</url-**pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-**timeout> <!-- in minutes -->
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</**welcome-file>
<welcome-file>index.html</**welcome-file>
<welcome-file>index.htm</**welcome-file>
</welcome-file-list>
---- stop -----
The next error you'll get is when you don't have mainDecorator setup in
your web.xml and the context-filter.
--- start----
<context-param>
<param-name>**mainDecoratorLocation</param-**name>
<param-value>component://**bridge-prestashop/widget/**
CommonScreens.xml</param-**value>
<description>The location of the main-decorator screen to use for
this webapp; referred to as a context variable in screen def XML
files.</description>
</context-param>
<filter>
<filter-name>ContextFilter</**filter-name>
<display-name>ContextFilter</**display-name>
<filter-class>org.ofbiz.**webapp.control.ContextFilter</**filter-class>
<init-param>
<param-name>**disableContextSecurity</param-**name>
<param-value>N</param-value>
</init-param>
<init-param>
<param-name>allowedPaths</**param-name>
<param-value>/error:/control:/**select:/index.html:/index.jsp:**
/default.html:/default.jsp:/**images:/includes/maincss.css</**param-value>
</init-param>
<init-param>
<param-name>errorCode</param-**name>
<param-value>403</param-value>
</init-param>
<init-param>
<param-name>redirectPath</**param-name>
<param-value>/control/main</**param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>ContextFilter</**filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener><listener-class>org.**ofbiz.webapp.control.**
ControlEventListener</**listener-class></listener>
<listener><listener-class>org.**ofbiz.webapp.control.**
LoginEventListener</listener-**class></listener>
----- stop ------
On 8/14/2012 02:52, Frédéric Bouquet wrote:
Hi,
Thanks for your answer.
In the logs, I can see a
Loading component : [practice]
but not LOADING WEBAPP corresponding to this project.
I don't have any error.
I can see in the access logs :
"GET /practice/ HTTP/1.1" 302 - [...]
GET /practice/control/main HTTP/1.1" 404 1018 [...]
So, the redirect works well (I have
a <%response.sendRedirect("**control/main");%> in my index.jsp at the
root of
the webapp) but the corresponding information are not found.
Here's my controller.xml :
<?xml version="1.0" encoding="UTF-8"?>
<site-conf
xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
"
xsi:noNamespaceSchemaLocation=**"
http://ofbiz.apache.org/dtds/**site-conf.xsd<http://ofbiz.apache.org/dtds/site-conf.xsd>
">
<include
location="component://common/**webcommon/WEB-INF/common-**
controller.xml"/>
<description>Practice Component Site Configuration File</description>
<owner>Copyright 2001-2009 The Apache Software Foundation</owner>
<handler name="screen" type="view"
class="org.ofbiz.widget.**screen.**ScreenWidgetViewHandler"/>
<request-map uri="main">
<security https="false" auth="false"/>
<response name="success" type="view" value="main"/>
</request-map>
<view-map name="main" type="screen"
page="component://practice/**widget/PracticeScreens.xml#**main"/>
</site-conf>
Do you need an other file to help me investigate the problem ? (In fact, I
made a copy paste from the tutorial)
Do I need the CommonScreens.xml to be present in the widget folder ? It
does not change anything in my case but I prefer asking.
Thank you
2012/8/14 Jacques Le Roux <[email protected]>
I'd suspect a typo somewhere, but just a guess...
Since it's a 404, I guess you have any clues in the log?
Jacques
Frédéric Bouquet wrote:
Hi folks,
I've started playing with Ofbiz a few days ago but I can't manage to
follow
the beginners tutorial [1].
In short, at the end of Part 1, when I try to access
http://localhost:8080/****practice/control/main<http://localhost:8080/**practice/control/main>
<http://**localhost:8080/practice/**control/main<http://localhost:8080/practice/control/main>>:
I get a 404 error.
I first tryed by creating all the files from scratch but it did not
work.
Then, I tryed to start by a ant create-component and change the files
the
tutorial says to create but I get the same result.
I also tryed with a create-component without modifying any file and
here,
I
had the possibility to access the web application.
Concerning the build, I tryed with 10.04.02 and from the trunk.
Does anyone have an idea ?
Thank you
[1] :
https://cwiki.apache.org/****confluence/display/OFBIZ/**<https://cwiki.apache.org/**confluence/display/OFBIZ/**>
OFBiz+Tutorial+-+A+Beginners+****Development+Guide<https://**
cwiki.apache.org/confluence/**display/OFBIZ/OFBiz+Tutorial+-**
+A+Beginners+Development+Guide<https://cwiki.apache.org/confluence/display/OFBIZ/OFBiz+Tutorial+-+A+Beginners+Development+Guide>
**>
--
Leonard Lin
Email: [email protected]
1136 N Larrabee Street, Apt 425
West Hollywood, CA 90069
Phone: +1 (213) 249 3260
Am Pfisterhölzli 2
CH - 8606 Greifensee
Switzerland
Phone: +41 (0)79 416 01 07