TILES: Converting registration page from struts example = nullpointer?

Discussion in 'Java' started by Jack, Jul 25, 2003.

  1. Jack

    Jack Guest

    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.getDefinition
    (FactorySet.java:156)
    at
    org.apache.struts.tiles.definition.ComponentDefinitionsFactoryWrapper.getDe
    finition(ComponentDefinitionsFactoryWrapper.java:124)
    at
    org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition
    (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
    Jack, Jul 25, 2003
    #1
    1. Advertising

  2. Jack

    Jack Guest

    "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.ActionComponentServlet</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
    Jack, Jul 28, 2003
    #2
    1. Advertising

  3. Jack

    Wendy S Guest

    "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.ActionComponentServlet</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.TilesRequestProcessor"
    />

    (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
    Wendy S, Jul 28, 2003
    #3
  4. Jack

    Jack Guest

    "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.TilesRequestProcessor"/>

    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
    Jack, Jul 29, 2003
    #4
  5. Jack

    Wendy S Guest

    "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
    Wendy S, Jul 29, 2003
    #5
  6. Jack

    Sudsy Guest

    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.
    Sudsy, Jul 29, 2003
    #6
  7. Jack

    Jack Guest

    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.
    Jack, Jul 29, 2003
    #7
  8. Jack

    Jack Guest

    "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.
    Jack, Jul 30, 2003
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sean Chou

    Struts Tiles

    Sean Chou, Jul 6, 2003, in forum: Java
    Replies:
    1
    Views:
    748
    Sean Chou
    Jul 11, 2003
  2. Jun
    Replies:
    1
    Views:
    1,338
    Wendy S
    Nov 17, 2003
  3. Conor
    Replies:
    0
    Views:
    933
    Conor
    Jan 15, 2004
  4. gilgantic

    Struts: Embedded Tiles

    gilgantic, Feb 4, 2004, in forum: Java
    Replies:
    0
    Views:
    425
    gilgantic
    Feb 4, 2004
  5. Rich M
    Replies:
    0
    Views:
    2,049
    Rich M
    Mar 5, 2004
Loading...

Share This Page