Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > TILES: Converting registration page from struts example = nullpointer?

Reply
Thread Tools

TILES: Converting registration page from struts example = nullpointer?

 
 
Jack
Guest
Posts: n/a
 
      07-25-2003
Hi all,

I've been working on converting the struts example app to tiles and have a
problem (I think with scopes) - I have moved the <html:form.... stuff into
a seperate tile, and call it from a main tile. Unfortuntely this has
broken it:

java.lang.NullPointerException
at org.apache.struts.tiles.xmlDefinition.FactorySet.g etDefinition
(FactorySet.java:156)
at
org.apache.struts.tiles.definition.ComponentDefini tionsFactoryWrapper.getDe
finition(ComponentDefinitionsFactoryWrapper.java:1 24)
at
org.apache.struts.tiles.TilesRequestProcessor.proc essTilesDefinition
(TilesRequestProcessor.java:180)

I also get problems after I submit the login form (actual form displays
fine, but bombs after submit). Oddly enough the form bean seems to be
created fine, it's just something on the Tiles parse that's not right.

Any Ideas where to look?

Cheers
 
Reply With Quote
 
 
 
 
Jack
Guest
Posts: n/a
 
      07-28-2003
"Wendy S" <> wrote in
news:bfs57d$7ld$:

> "Jack" <> wrote in message
> news:Xns93C3A676DD306neverinamillioncom@127.0.0.1. ..
>> Any Ideas where to look?

>
> Can you post the the JSP for the main tile and the included one, and
> tiles-defs.xml if you're using it. Looks like it just can't find one
> of the tiles.
>


Hi Wendy,

I had a little success over the weekend with this, by replacing

<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
with
<servlet-class>org.apache.struts.tiles.ActionComponentServl et</servlet-
class>

So it looks like the default actionservlet doesnt want to play ball. I
seem to recall that the latter is not depreciated, so not entirely sure
what's ideal. Makes sense though as it was Actions that failed with
hindsight.

Thanks
J
 
Reply With Quote
 
 
 
 
Wendy S
Guest
Posts: n/a
 
      07-28-2003
"Jack" <> wrote in message
news:Xns93C66DA70DE8Dneverinamillioncom@127.0.0.1. ..
> I had a little success over the weekend with this, by replacing
> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
> with
>

<servlet-class>org.apache.struts.tiles.ActionComponentServl et</servlet-
> class>


What do you have in struts-config.xml? I have ActionServlet (the first line
above) in web.xml, then struts-config has the Tiles plugin set up:

<!-- ========== Tiles plug-in setting settings =================== -->
<!-- Here we specified the tiles plug-in.
This plug-in register appropriate Request Processor -->
<controller processorClass="org.apache.struts.tiles.TilesReque stProcessor"
/>

(and further down)

<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config"
value="/WEB-INF/tiles-defs.xml" />
<set-property property="definitions-debug" value="2" />
<set-property property="definitions-parser-details" value="2" />
<set-property property="definitions-parser-validate" value="true" />
</plug-in>

--
Wendy in Chandler, AZ


 
Reply With Quote
 
Jack
Guest
Posts: n/a
 
      07-29-2003
"Wendy S" <> wrote in
news:bg3hha$7sh$:

> What do you have in struts-config.xml? I have ActionServlet (the
> first line above) in web.xml, then struts-config has the Tiles plugin
> set up:


Hi Wendy,

I added the line:

<controller
processorClass="org.apache.struts.tiles.TilesReque stProcessor"/>

and all systems go, many thanks!

Perhaps you can help me with another issue which is when I have a user
access a restricted page I throw them to the login page, this isnt a
redirect as the url doesnt change. what I want the login page to do on
success is to pop them back to the calling page, but it doesnt seem to want
to play ball... if I add:

return (mapping.getInputForward());

it simply redirects back to the login page which is wrong. Obviously I
need this to be dynamic as

return (mapping.findForward("mainmenu"));

will always forward to the same place.

Thanks!
J
 
Reply With Quote
 
Wendy S
Guest
Posts: n/a
 
      07-29-2003
"Jack" <> wrote in message
news:Xns93C78E7DC1D51neverinamillioncom@127.0.0.1. ..
> Perhaps you can help me with another issue which is when I have a user
> access a restricted page I throw them to the login page, this isnt a
> redirect as the url doesnt change. what I want the login page to do on
> success is to pop them back to the calling page, but it doesnt seem to

want
> to play ball... if I add:
> return (mapping.getInputForward());
> it simply redirects back to the login page which is wrong. Obviously I
> need this to be dynamic as
> return (mapping.findForward("mainmenu"));
> will always forward to the same place.


The easiest thing to do, although it doesn't feel very Struts-like, is to
put something in the session session.setAttribute("returnTo",
"editSomething.do"); Then use that something to construct an ActionForward:

Here's a snippet of code from my project:

String path = "/" + request.getAttribute( "returnTo" )
+ "?selectedId=" + selectedId
+ "&userAction=" + request.getAttribute( "userAction" )
+ "&returningFromResolution=true";

log.debug( "Returning a forward to " + path + " with
redirect=true");

return new ActionForward( path , true );

(The 'true' in the ActionForward constructor says to do a redirect, so you
get the ugly URL with the parameters showing, but it was necessary to get
the URL to change for another part of my project to work right. That might
not be the case for you, so try it without that parameter first.)

--
Wendy in Chandler, AZ


 
Reply With Quote
 
Sudsy
Guest
Posts: n/a
 
      07-29-2003
Jack wrote:
<snip>
> Perhaps you can help me with another issue which is when I have a user
> access a restricted page I throw them to the login page, this isnt a
> redirect as the url doesnt change. what I want the login page to do on
> success is to pop them back to the calling page, but it doesnt seem to want
> to play ball... if I add:
>
> return (mapping.getInputForward());
>
> it simply redirects back to the login page which is wrong. Obviously I
> need this to be dynamic as
>
> return (mapping.findForward("mainmenu"));
>
> will always forward to the same place.
>
> Thanks!
> J


Save the result from getInputForward() in a hidden field during the
FIRST invocation of your login servlet. Waiting until the second
time through (after user hits the submit button) will indeed give
you the login page as the forwarding page.

 
Reply With Quote
 
Jack
Guest
Posts: n/a
 
      07-29-2003
Sudsy <> wrote in
news::

> Save the result from getInputForward() in a hidden field during the
> FIRST invocation of your login servlet. Waiting until the second
> time through (after user hits the submit button) will indeed give
> you the login page as the forwarding page.
>


Makes perfect sense when you put it like that only problem I have with
that is because it's a DynaValidatorForm the Action wont be called until
submit, so I cant see how I could pass the referrer without doing as Wendy
suggests and pass it to the jsp in the querystring somehow, which is a
little nasty as it means my basic forwards need hacking to add
querystrings.


Flow currently is:
Restricted action --> login.jsp --> loginaction --> login.jsp

Thanks
J.
 
Reply With Quote
 
Jack
Guest
Posts: n/a
 
      07-30-2003
"Wendy S" <> wrote in
news:bg5ulj$opm$:


> The easiest thing to do, although it doesn't feel very Struts-like, is
> to put something in the session session.setAttribute("returnTo",
> "editSomething.do"); Then use that something to construct an
> ActionForward:
>


Hi Wendy,

Only reason for not doing it that way is that it's not multy-window safe.
Been experimenting and trying to get the referrer from the logon action
(forwarding direct to the logon action instead of the logon jsp now) and
that still doesnt work though.

Seems a bit daft that something so simple in theory is so hard in practice
:-/

Cheers
J.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it safe to point to Internet for locating struts DTD files in struts TLDs and XML files? Katie Wright Java 8 01-07-2005 03:37 PM
Multiple page example with Struts Arun Nair Java 1 07-09-2004 08:05 AM
Multiple page example with Struts Arun Nair Java 0 07-09-2004 05:10 AM
Integrate a Struts app with a non-struts app jc1771 Java 0 12-28-2003 06:36 PM
Struts Installation - missing struts.tld??? Jason Us Java 0 10-03-2003 11:36 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57