Menu

First steps

2003-02-08
2003-02-09
  • Alex McLintock

    Alex McLintock - 2003-02-08

    Hi folks,

    I'm trying to review the Struts in Action and Oreilly struts books.

    I'm trying to extend Artimus by duplicating the article code but with a different package name ("book") and a different table "artimus_book" instead of "article" and "artimus_article".

    I have the new code compiled, but am hitting problems trying to create the table.

    It creates the usual tables, but falls over when trying to create mine....

    I have created my own properties file which I think is loaded and includes these three SQL statements....

    book.table.create
    book.insert.welcome
    book.key.first

    It looks like the first is failing with the following exception....

    Unfortunately I can't seem to get MySQL database logging, so I can't see what is going wrong...

    Any ideas?

    Alex

    java.lang.NullPointerException
            at org.gjt.mm.mysql.Statement.executeUpdate(Statement.java:209)
            at org.gjt.mm.mysql.jdbc2.Statement.executeUpdate(Statement.java:97)
            at com.codestudio.sql.PoolManStatement.executeUpdate(PoolManStatement.java:218)
            at org.apache.commons.scaffold.sql.StatementUtils.executeUpdate(Unknown Source)
            at org.apache.commons.scaffold.sql.StatementUtils.executeUpdate(Unknown Source)
            at org.apache.commons.scaffold.sql.AccessBase.executeUpdate(Unknown Source)
            at org.apache.artimus.book.Access.createResources(Unknown Source)
            at org.apache.artimus.CreateResources.execute(Unknown Source)
            at org.apache.struts.scaffold.ProcessAction.executeLogic(Unknown Source)
            at org.apache.struts.scaffold.BaseHelperAction.executeLogic(Unknown Source)
            at org.apache.struts.scaffold.BaseAction.execute(Unknown Source)
            at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:446)
            at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:266)
            at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292)
            at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)

     
    • Ted Husted

      Ted Husted - 2003-02-08

      The implication would be that the book properties file isn't loading or the application is requesting a entry that doesn't exist. To load another properties file, you should subclass or change ArtimusServlet [15.5.3]. You can also add the entries for your package to one of the existing files. Just keep using "book." so that they don't clash with "ariticle." They all get appended into the same properties object in the end.

      -Ted.

       
    • Alex McLintock

      Alex McLintock - 2003-02-08

      OK, that bit is solved - I was using "books" instead of "book" in the properties file.... thus nothing was found.

      Next problem is with this line in my new Access.java

      Integer key = (Integer) StatementUtils.getColumn(               null,1 ,getCommand(KEYS_NEXT), keyName);

      It is returning null.

      StatementUtils is in Scaffold - and I can't seem to find the documentation for it in the artimus download. Am I being stupid?

       
      • Ted Husted

        Ted Husted - 2003-02-08

        The source code for Scaffold is bundled with the book download and call also be downloaded from the files section here. It's also available under CVS for browsing in the Jakarta Commons sandbox.

        http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/sql/

        That particular statement just fetches the value of a field and then increments it. There's a key table in the database, which is where the keyname comes in. If you are adding keys for one of your own tables, then you would need to add a corresponding key to the key table.

        Most of Scaffold is only documented through the source right now. The point of the exercise is not so much Scaffold itself, but how to interact with things like Scaffold. Most of the teams I've worked with already have something they want to use for the data access, usually developed in house.

        Right now, I'm getting ready to dissemble Scaffold into some of the other Commons packages, like Commons SQL. Of course, when that happens I'll relink and rerelease this sample application to use the new packages.

        If you get stuck on something, you can also get me directly at ted at husted.com.

        -T.

         
    • Alex McLintock

      Alex McLintock - 2003-02-08

      Thanks for the help Ted....

      I was kind of expecting "artimus" to be a "best of breed" example of a struts application - the correct way of doing things. But I think I see now that since scaffold is optional, this is just an possible example....

      I *think* I have created an entry in the keys table for my new table....
      Aaargh, no I haven't ---- that had "books" by mistake too..... but fixing that and.... looks much better.....

      Ok, last question for today.... (probably in the book)....

      What creates javascript function validateArticleForm(this)

      My screen for entering a book is almost identical to the article one except
      validateBookForm(this)
      doesn't exist - and the introductory script open tag doesn't either. Most of the other javascript seems to appear all right.
      ....
      (goes to look it up in Struts in Action....)

      AHA - that tells me that there is a validation.xml which I haven't looked at yet.... needs editing.....

      Getting there......

      Thanks again

       
      • Ted Husted

        Ted Husted - 2003-02-09

        What Artimus demonstrates is implementing an application based on what Fowler calls a Domain Model and hooking that up to Struts. The idea is that the actual Artimus application lives above Struts. So it's not a Struts application, but an application that has been connected to  Struts.

        The real point of  Struts is to give you a way to ~present~ your application. In doing this, Struts sketches out a nice little architecture that you can actually use as the base of a web-locked application. But, personally, I recommend creating your own architecture and then hooking that to Struts.

        The real point of Artimus is to show how much can be done without tying everything directly to Struts. The thing to note is how few Struts classes it actually uses, and how it uses them.

        Meanwhile, I reckon that you've extended the validation.xml to accomodate your new form =:0)

        -T.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.