@Dave,
Great!
Your explanation is very clear and in detail. It really helps me a lot.
I think I understand the overall process.: )
Thanks for your time.
Best regards,
Wuxia Jin
On Sat, Feb 24, 2018 at 3:02 PM, 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,
> >
> > > class="org.apache.roller.weblogger.ui.struts2.editor.
> BookmarkEdit">
> > bookmarkAdd
> > bookmarkForm.add.title
> > .BookmarkEdit
> > bookmarks
> > bookmarks
> >
> >
> > > class="org.apache.roller.weblogger.ui.struts2.editor.
> BookmarkEdit">
> > bookmarkEdit
> > bookmarkForm.edit.title
> > .Bo