Yes, that looks good to me. Glad to help.
Dave On Sun, Feb 25, 2018 at 12:37 PM x86 wj <wj86...@gmail.com> wrote: > @Dave @Greg, > > 1. DMI. I didn't even know that. Thank you for telling me about it. : > ) > > 2. According to the source code and your answers, I think the handing > process is much clearer for me. > > When a request is coming...it will pass through a lot of filters in order. > web.xml illustrates the filtering order, and the last two filters are > *RequestMappingFilter* and *struts2*. > > (1) When the request is passing in RequestMappingFilter. > > org.apache.roller.weblogger.ui.rendering.web.WeblogRequestMapper.handleRequest()process > this request. > It parses the request url, and finds a certain XXXServlet to process this > request. So the XXXServlet will really start processing the business logic > about the request. > This part is mainly located in > org.apache.roller.weblogger.ui.rendering.servlet, focusing on weblog page > rendering system. > > (2)If the request is not being processed, then it will pass in the last > filter- struts2. struts2.xml has mapped the action name to action class. > It will find a certain XXXActionClass to process the request. So XXXAction > Class will really start processing the business logic about the request. > This part mainly is located in org.apache.roller.weblogger.ui.struts2, > focusing on weblog admin and interface action, such as bookmark, category, > entry,..... > > Great. I think it is right. aha? > > Thanks a lot for your help. I really appreciate it. > Best regards, > Wuxia > > > On Sun, Feb 25, 2018 at 3:47 AM, Greg Huber <gregh3...@gmail.com> wrote: > > > good write up! > > > > Cheers Greg > > > > On 24 February 2018 at 20:02, Dave <snoopd...@gmail.com> wrote: > > > > > Hi Wuxia Jin, > > > > > > Some answers below... > > > > > > > > > > The processing of an incoming request is right as what I said? > > > > > > Yes, that is mostly correct, but not all requests are handle by Struts. > > > > > > To understand how Roller works, you should also look at the web.xml > file > > > and how it maps URL paths to Java classes. > > > > > > Also, understand that there are two parts of Roller: > > > > > > 1) the weblog editor and admin interface, which exists at the URL path > > > /roller-ui and is written using Struts and JSP pages (see the > struts.xml > > > and tiles.xml to see how Struts is configured) and > > > > > > 2) the Roller weblog page rendering system, which uses a set of > Servlets > > > which call the Velocity template engine to display weblog pages using > > > Velocity templates. > > > > > > In the web.xml there is a RequestMapping filter. If that filter sees a > > > request for a weblog page then it calls a servlet to display the weblog > > > page or weblog RSS feed (using Velocity). > > > > > > If the RequestMapper does not handle a request, then the next filter, > > which > > > is the Struts filter, will handle the request and determine which > Struts > > > action is to be called. > > > > > > > > > > *2. From the structs, each "action" corresponds to a "action class". > > > Aslo, > > > > There is more than one action is processed by the same action class.* > > > > If so, *how does execute() distinguish the two different actions to > > > process > > > differently?* > > > > > > The BookmarkEdit action is called twice. > > > > > > First, it is called with no method name specified in the URL and the > > > execute() method returns INPUT, which tells struts to display the > > > ".BookmarkEdit" Tile which includes the BookmarkEdit.jsp page. That > > causes > > > the Bookmark Edit page to be displayed to the user. > > > > > > Second, when a user clicks the Save button then Bookmark edit action is > > > called again but this time with the save method specified in the URL > (by > > a > > > !save notation). That means that the save() method gets called, and a > new > > > bookmark is added or an existing bookmark is updated. > > > > > > > > > > (b) Another question is that, in class BookmarkEdit, there is > "save()" > > > > method besides "myPrepare()" and "execute()". > > > > From the code,* I cannot clearly see how the save() method is called, > > or > > > > who will call save() method?* > > > > > > Yes, that is confusing and sort of a hack. There is a form parameter > > that > > > carries an action name of either "bookmarkAdd" or "bookmarkEdit" and > > there > > > is a method called isAdd() which looks at that parameter and decides > > > whether to add a new bookmark or update an existing bookmark. > > > > > > Hope that helps. > > > > > > Best regards, > > > Dave > > > > > > > > > On Sat, Feb 24, 2018 at 2:02 PM x86 wj <wj86...@gmail.com> wrote: > > > > > > > hi Greg, > > > > > > > > *1. According to your explanation, I try to express the request > > > > processing. * > > > > When a request comes in: > > > > (1) Firstly, several filterings will filter the request. > > > > (2) Then, as you said, WeblogRequestMapper is the overall entry for > > > > processing all request. WeblogRequestMapper.handleRequest() will > > parse > > > the > > > > requesting url, then find the corresponding "Action name" to process > > the > > > > request. > > > > (3) After finding the "Action name", then corresponding Action Class > > will > > > > really process the business function. while the mapping from "action > > > name' > > > > to "action class" is specified in Struts.xml. > > > > (4) The 'Action class' will process the logic. It firstly runs > > > > its myPrepare() method, then call the execution() method. > > > > (5)After processing the execute() method, then continue the pass the > > > > several filterings. > > > > > > > > The processing of an incoming request is right as what I said? > > > > > > > > *2. From the structs, each "action" corresponds to a "action class". > > > Aslo, > > > > There is more than one action is processed by the same action class.* > > > > For example, > > > > > > > > <action name="bookmarkAdd" > > > > class="org.apache.roller.weblogger.ui.struts2.editor. > > > BookmarkEdit"> > > > > <param name="actionName">bookmarkAdd</param> > > > > <param name="pageTitle">bookmarkForm.add.title</param> > > > > <result name="input" type="tiles">.BookmarkEdit</result> > > > > <result name="success" type="chain">bookmarks</result> > > > > <result name="error" type="chain">bookmarks</result> > > > > </action> > > > > > > > > <action name="bookmarkEdit" > > > > class="org.apache.roller.weblogger.ui.struts2.editor. > > > BookmarkEdit"> > > > > <param name="actionName">bookmarkEdit</param> > > > > <param name="pageTitle">bookmarkForm.edit.title</param> > > > > <result name="input" type="tiles">.BookmarkEdit</result> > > > > <result name="success" type="chain">bookmarks</result> > > > > <result name="cancel" type="redirectAction"> > > > > <param name="actionName">bookmarks</param> > > > > <param name="weblog">${weblog}</param> > > > > <param name="folderId">${folderId}</param> > > > > </result> > > > > <result name="error" type="chain">bookmarkEdit</result> > > > > </action> > > > > > > > > (a) we can see "bookmarkAdd" and "bookmarkEdit' the two actions are > > both > > > > processed by "org.apache.roller.weblogger.ui.struts2.editor. > > > BookmarkEdit". > > > > But there is only one execute() method in class BookmarkEdit. It > means > > > > "bookmarkAdd' and "bookmarkEdit" are processed by the same > execution() > > > > method? > > > > If so, *how does execute() distinguish the two different actions to > > > process > > > > differently?* > > > > > > > > (b) Another question is that, in class BookmarkEdit, there is > "save()" > > > > method besides "myPrepare()" and "execute()". > > > > From the code,* I cannot clearly see how the save() method is called, > > or > > > > who will call save() method?* > > > > > > > > > > > > > > > > I am new to structs and roller. A lot of details I would like to ask > > and > > > > hope make it clear. > > > > Thank you for your help. > > > > Best regards, > > > > Wuxia Jin > > > > > > > > > > > > On Sat, Feb 24, 2018 at 12:07 PM, Greg Huber <gregh3...@gmail.com> > > > wrote: > > > > > > > > > .....should be WeblogRequestMapper > > > > > > > > > > Cheers Greg > > > > > > > > > > On 24 February 2018 at 04:39, x86 wj <wj86...@gmail.com> wrote: > > > > > > > > > > > Roller is in a web architecture of "presentation -> business > logic > > -> > > > > > > persistent layer". But the project is complex. From the source > > code, > > > I > > > > > have > > > > > > no idea which packages(or classes) are responsible for the > > > controller. > > > > > The > > > > > > following will list an example to express my meaning. > > > > > > > > > > > > For example, Jpetstore is a small project with only 24 classes. > > > > > > https://github.com/mybatis/jpetstore-6/blob/master/src/ > > > > > > main/java/org/mybatis/jpetstore/web/actions/OrderActionBean.java > > > > > > > > > > > > This link shows that OrderActionBean is one of the controller > class > > > in > > > > > > web.action package. OrderActionBean.listOrders is one function > > entry > > > > > > provided by system. > > > > > > > > > > > > So, I would like to know, in roller,* where can I find the > similar > > > > > > 'controllerClass.method()' that clearly present function's > entry*. > > > Can > > > > > you > > > > > > give me some example? > > > > > > > > > > > > Thanks a lot for your time. I really need your help. > > > > > > Best regards, > > > > > > Wuxia Jin > > > > > > > > > > > > > > > > > > > > >