incubator-jspwiki-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Jaquith <andrew.r.jaqu...@gmail.com>
Subject Re: new pages
Date Fri, 17 Apr 2009 17:52:45 GMT
I've started implementing option (2) below. It seems to help. However,
EditActionBean (and thus editing) is still hosed because of some work
I was doing integrating it with SpamFilter. I dropped that for a
little while to focus on core bug-fixes after JCR landed, but now I'm
revisiting it. With luck, I'll be able to get the editing features
working again over the next week.

Andrew

On Thu, Apr 16, 2009 at 6:18 PM, Andrew Jaquith
<andrew.r.jaquith@gmail.com> wrote:
> Funny, I was drafting an e-mail on this very subject. Here it is...
>
> ---
>
> As the 3.0 trunk starts to settle down, I'm headed back to the JSP
> tier to do some work. I wanted to get your thoughts on
> WikiPageTypeConverter -- an important component of how JSPWiki
> interacts with the Stripes layer. I'm thinking of changing how it
> works so that it resolves non-existent WikiPages.
>
> Background: the Stripes TypeConverter classes are pretty nifty. They
> extract parameters from the request stream and convert them into
> objects the target ActionBean wants. For example, if an ActionBean has
> a get/set property called "counter" and its return type is an integer,
> Stripes will convert the value of the request parameter "counter"
> (which is a String) into the correct integer, and cause the
> ActionBean's setCounter(int) method to be called with the converted
> integer value. For JSPWiki, I've created TypeConverter classes for
> wiki Groups, WikiPages, and Principals. The net effect is that when
> one of our ActionBeans is invoked by user's browser in an HttpRequest,
> all of the parameters are magically parsed, converted into their
> correct target types, and bound to the ActionBean. Once the properties
> are converted and populated, they become available for an event
> handler method to use.  It works like magic.
>
> Now, the WikiPageTypeConverter I wrote is pretty interesting. When we
> see a String representing the name of a WikiPage, we look it up in the
> ContentManager. If it's not found, we return a null. Meaning, "we
> didn't find the page because it's not in the repository." The
> consequences of this is what is causing the problem. What this means
> is that ActionBeans with a WikiPage property on them won't have a
> WikiPage bound to them when we finally invoke the event handler
> method. For example, EditActionBean's "edit" method (which starts the
> editing screen) gives an NPE if we try to edit (create!) a page that
> doesn't exist, because the TypeConverter looked up the page, and not
> finding it, returned null as it should have.
>
> This is clearly a problem.
>
> There are two ways of dealing with this: (1) changing the behavior of
> WikiPageTypeConverter so that it returns a valid WikiPage object
> whenever it is presented with a non-null page name, even if the page
> does not exist. The other solution is to (2) ensure that the
> WikiActionBean that depends on the WikiPage has the correct code to
> detect the non-existent page condition, and then can create a new
> WikiPage to fill that gap. ViewActionBean provides an example of (2).
>
> I think (1) is a better option because it means we fix the problem
> once in WikiPageTypeConverter, and don't have to write special
> handling code in every WikiPage-related ActionBean. However, I don't
> fully understand how this would interact with ContentManager. Can you
> create new "temporary" Nodes that aren't persisted? Do we need a
> WikiPage method like isSaved() or similar to indicate whether it's
> been persisted to JCR? Dunno how hard this is.
>
> Andrew
>
> On Thu, Apr 16, 2009 at 5:05 PM, Janne Jalkanen
> <Janne.Jalkanen@ecyrd.com> wrote:
>> Heya!
>>
>> Could you Andrew walk me through exactly how new pages are supposed to be
>> created? As far as I can tell, everything just explodes if you try to edit a
>> page which does not exist, and there really isn't a place to call
>> ContentManager.addPage() either, since the WikiPage gets set in
>> WikiPageConverter, and non-existent page is considered an error.
>>
>> /Janne
>>
>

Mime
View raw message