[prev in list] [next in list] [prev in thread] [next in thread] 

List:       japple-dev
Subject:    RE: [japple-dev] PostGreSQL update/insert not working??
From:       "William G. Thompson, Jr." <wgthom () tnt-web ! com>
Date:       2002-06-26 18:59:19
[Download RAW message or body]

Jonathan,

I've added a delete example to the Tutorial application.  You can download
the code from: http://www.japple.org/builds/webapps/tutorialwithdelete.war
The DishList example now has a dishEdit page with a delete button that
removes a record from the database.

Here's the steps I took to make this work:

1) Edit dishEdit.html
Added a new "Delete" button with the following code:
  <input type="button"
         onClick="javascript:saveAndExit('dishEdit',
          'japple.tutorial.DishList','dc.selectedDish=setAbsolute(null)');"
   value="Delete">

2) Created japple.tutorial.DishDelete Statement JMO
    delete from dish where name = :name

3) Added japple.tutorial.DishDelete Statement to the 'Delete Actions' 
   in the 'Save Activity' of the japple.tutorial.Dish DataProfile

Hope this helps! :)

later.
Bill
--
William G. Thompson, Jr.
Chief Japple Evangelist | www.japple.org
Saucon Technologies
bthompson@saucontech.com | +1 908 947 7145 | www.saucontech.com

On Tue, 25 Jun 2002, Lonon, Jonathan B wrote:

> Um, still didn't work.  The log is not even showing the delete which I know
> I have setup correctly in the dish dataprofile.  I think it has something to
> do with the dishEditHandler, which has instructions about insert and update,
> but nothing about delete.  My delete button is on the same page as the
> save/exit and cancel buttons.  No errors, but I guess I'm stuck again.  Let
> me know if that sounds correct or not.  I'll check back later this evening.
> 
> Thanks,
> Jonathan.
> 
> -----Original Message-----
> From: abishop@saucontech.com [mailto:abishop@saucontech.com]
> Sent: Tuesday, June 25, 2002 9:07 AM
> To: japple-dev@japple.org
> Subject: RE: [japple-dev] PostGreSQL update/insert not working??
> 
> 
> 
> 
> Jonathan -
> 
> The scenario you mentioned sounds typical for deleting a single item. In
> this
> case, you're deleting the whole thing, not just a sub-element of it.
> My example regarding removeElementAt() was more for deleting sub-components
> of a
> parent item. Deleting the entire parent item is in fact simpler.
> 
> You are correct in noticing that Japple calls a saveAndExit when you delete.
> As
> I mentioned before, all you need to do is modify state properly, and japple
> will
> figure out whether it needs to insert, update, or delete based on the before
> and
> after picture. For your example, all you need to do is set the datamodel
> equal
> to null on the item you're looking to delete. For example, if your
> dataprofile's
> start activity puts data into dc.item, you want the code on your delete
> button
> to look something like:
> saveAndExit('edit','TargetPageHere','dc.item=setAbsolute(null)')
> This will set the dc.item area of state equal to null, and call the built-in
> javascript function saveAndExit to perform the actual delete. (I use the
> setAbsolute() keyword here to ensure that dc.item gets set to null, even if
> my
> form has elements which point to areas under dc.item. Otherwise, dc.item
> might
> get re-loaded with the values of those form elements when the form is
> re-posted.)
> 
> Next, you want to make sure you have the appropriate delete statement(s) in
> your
> dataprofile. You should have a save activity with dc.item as its source and
> target accessors, and it should have a delete action with the appropriate
> statement. Usually, you want your delete actions to use the start activity's
> key
> accessor, which should be the item's unique identifier. For example, if the
> unique identifier of the item table is in a column called itemid, and gets
> put
> into state as itemID, then your delete statement should look like: delete
> from
> item where itemid = :itemID
> Remember, the source accessor of the delete statement is dc.item, so be sure
> your start activity for dc.item includes the itemid column as part of the
> select.
> 
> Finally, check to make sure the delete statement is being called properly.
> Pass
> the &traceEventOn=DBAccess parameter on the url to turn on tracing for
> dbstatements for the session. Try your delete, then check the trace file
> (located at [web app context path]/WEB-INF/japple/logs/[username].trace).
> Make
> sure the variables are being substituted properly in your delete statement.
> 
> -Adam Bishop
> 
> 
> 
> 
> 
> 
> 
> 
> 
> "Lonon, Jonathan B" <Jonathan.B.Lonon@bankofamerica.com> on 06/24/2002
> 06:53:11
> PM
> 
> Please respond to japple-dev@japple.org
>  
> 
>  
> 
>  
> 
> 
> 
>                                                               
>                                                               
>                                                               
>  To:      "'William G. Thompson, Jr.'" <wgthom@tnt-web.com>   
>                                                               
>  cc:      "'japple-dev@japple.org'"                           
>           <japple-dev@japple.org>(bcc: Adam Bishop/Saucon     
>           Technologies)                                       
>                                                               
>                                                               
>                                                               
>  Subject: RE: [japple-dev] PostGreSQL update/insert not       
>           working??                                           
>                                                               
> 
> 
> 
> 
> 
> 
> 
> Really like what I see.  I read some things on the site that I didn't get to
> read before.  Interested in the services and how to access them.  Need a
> little more docs, even java docs would be helpful.
> 
> First though, I am just getting back to this after a week, and still getting
> stuck on how to delete an item in dishList on the tutorial.  Everything I'm
> trying is not working.  I can modify (update) and add new (insert) dishes
> all day long, but a simple example of deleting would be nice.  For example,
> Adam's help on removeElementAt() gave a static parameter of 1.  Would I not
> need a way to provide a dynamic variable such as the dc.selectedDish value.
> (a. click the dish, b. view the data to be sure this is one I want to
> delete, c. choose a delete link or delete button on the button form, d. use
> the confirmDelete method -- which seems to call save/exit, e. be returned to
> the list with the state saved and the list updated because the dataprofile
> has been saved via save/exit.  Will this scenario work?  Am I thinking about
> the flow correctly?  Is there a dynamic property about the list accessible?
> What would really be nice (eventually) is to do the delete checkbox style as
> used in japple, but I just want the basics for the moment.
> 
> I want to take advantage of the security service after getting past deleting
> from the database.  Since I plan to start with the logon and registration
> screens in the app, this would be a big plus!  If I understand the docs I
> read, I should not have to write a whole lot to enable login to my app using
> available japple components?
> 
> Thanks, Jonathan.
> 
> -----Original Message-----
> From: William G. Thompson, Jr. [mailto:wgthom@tnt-web.com]
> Sent: Friday, June 21, 2002 4:32 PM
> To: Lonon, Jonathan B
> Subject: RE: [japple-dev] PostGreSQL update/insert not working??
> 
> 
> Johanthan,
> 
> Hi.  Just checking in to see how you are doing with Japple and to get your
> thoughts on the approach.  Don't hesitate to contact me directly if you
> need anything.
> 
> Saucon Tech, the sponsor of Japple, provides training, support, and
> services around Japple if you ever need it.  Of course we'll just as happy
> to help you out on the mailing lists for free ;)
> 
> Cheers,
> Bill
> --
> William G. Thompson, Jr.
> Chief Japple Evangelist | www.japple.org
> Saucon Technologies
> bthompson@saucontech.com | +1 908 947 7145 | www.saucontech.com
> 
> 
> On Tue, 18 Jun 2002, Lonon, Jonathan B wrote:
> 
> > I will check out the .war.  Another question:
> >
> > I created a DBSTATEMENT JMO called DishDelete and added it to the
> > DataProfile for my japple.foobar app.  I looked at dishEdit.html for a
> place
> > to add a Delete This Dish link.  I have the following already
> >
> > <a
> >
> href="japple?PAGE=japple.tutorial.DishEdit&dc.selectedDish=null&traceEventOn
> > =DBAccess" >Add New Dish</a>
> >
> > but not sure how to use japple for appropriate delete method.  I know this
> > one should be really easy, but I'm pretty new at the JMO/HTML/JSP combo
> > approach, so I may have questions for a few days.
> >
> > Jonathan.
> >
> > -----Original Message-----
> > From: abishop@saucontech.com [mailto:abishop@saucontech.com]
> > Sent: Tuesday, June 18, 2002 3:16 PM
> > To: japple-dev@japple.org
> > Subject: RE: [japple-dev] PostGreSQL update/insert not working??
> >
> >
> >
> >
> > You can have several db pools defined in your japple.xml file, and in fact
> > your
> > application may use several different pools, even in the same transaction.
> > I would suggest using the starterapp.war as a foundation to build your new
> > app
> > on. It is pretty close to an "empty shell" of an app, and you should be
> able
> > to
> > create an application from scratch without any pre-existing dependencies.
> >
> > -Adam Bishop
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > "Lonon, Jonathan B" <Jonathan.B.Lonon@bankofamerica.com> on 06/18/2002
> > 02:57:43
> > PM
> >
> > Please respond to japple-dev@japple.org
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >  To:      "'japple-dev@japple.org'" <japple-dev@japple.org>
> >
> >  cc:      (bcc: Adam Bishop/Saucon Technologies)
> >
> >
> >
> >  Subject: RE: [japple-dev] PostGreSQL update/insert not
> >           working??
> >
> >
> >
> >
> >
> >
> >
> >
> > Thanks!  Select, update, and insert are now all working with the cygwin
> > version of postgresql.  I am ready to start on an app now!
> >
> > The problem was that I was using PostgresqlTutorialDB instead of
> TutorialDB
> > as the pool name.  I also commented the mckoi pool section which I would
> > think can still be uncommented?  Or can you only have one pool defined at
> a
> > time in the japple.xml file?  I will try it to see, but thought I would
> ask
> > anyway.
> >
> > I guess I have a few related questions:
> >
> > As I start on a new application from the ground up, what are the basic
> > things I need to know to break the dependency on the tutorial
> dependencies,
> > upon which the tutorial example seems to be based?  For example, where do
> I
> > have to change things so that TutorialDB is not the required name for the
> > pool, etc., or is this something I cannot change?
> >
> > I think I have enough to go forward on my project, but I know I will need
> to
> > use some of the other types that are in the object list (and thought I saw
> > something somewhere about various document types, such as Word -- .doc,
> > etc.).  Is there a date on a more complete document or some samples that
> can
> > be reviewed of HTML and JSP Handlers that might aid with rapid app dev?
> >
> > Thanks abishop, Mark and Patrick for the quick responses!
> > Jonathan.
> >
> > -----Original Message-----
> > From: Mark Deneen [mailto:mdeneen@japple.org]
> > Sent: Tuesday, June 18, 2002 12:49 PM
> > To: 'japple-dev@japple.org'
> > Subject: RE: [japple-dev] PostGreSQL update/insert not working??
> >
> >
> > I just tested the tutorial in postgres 7.2.1, running on redhat linux 7.1,
> > and it worked fine.
> >
> > tutorial=> select name, description from dish;
> >            name            |              description
> > ---------------------------+----------------------------------------
> >  Oysters On The Half-shell | Very fresh...
> >  Curry Goat                | Jamaican favorite
> >  Gulab Jamun               | Fried Indian dough balls with cardamom
> >  Couscous                  | Traditional Moroccan delicacy
> >  Ceasars Salad             | Very fresh...
> >  Ramen                     | Tasty Ramen Noodles
> >  Hot Dogs                  | Meat of unknown origin
> > (7 rows)
> >
> > As you can see, I've added two tasty dishes, which kept me alive through
> > college.
> >
> > If I had to guess what was going wrong, I would say that you might still
> > be using the mckoi embedded database, even if you think you are using
> > postgresql.
> >
> > In your japple.xml file (down in WEB-INF/japple/conf), comment out the
> > mckoi database pool entry, and add one for postgres.  There should be an
> > example which is commented out.
> >
> > Here is an example of what it should look like.  Yours should be almost
> > exactly the same, except for the host url, and maybe the user/password.
> >
> > <pool name="TutorialDB">
> >     <driver>org.postgresql.Driver</driver>
> >     <url>jdbc:postgresql://YOURHOST/tutorial</url>
> >     <user>tutorial</user>
> >     <password>tutorial</password>
> >     <maxConnections>25</maxConnections>
> >     <idleTimeExpiration>300000</idleTimeExpiration>
> >     <activeTimeExpiration>0</activeTimeExpiration>
> >     <connectionsAlwaysAvailable>0</connectionsAlwaysAvailable>
> >     <cleanupFrequency>300000</cleanupFrequency>
> > </pool>
> >
> >
> > You still have to name the pool TutorialDB because all of the tutorial
> > statements are pointing to the TutorialDB database pool, not
> > PostgresTutorialDB.
> >
> > Try this out, and tell us if it helps!
> >
> > -M
> >
> > On Tue, 18 Jun 2002, Lonon, Jonathan B wrote:
> >
> > > Yes, trace file has correct substituted values.
> > > Yes, I'm using the pgjdbc2.jar file which was the latest when I
> downloaded
> > > it a few weeks ago.
> > > The statement is being call in the dataprofile.
> > > Yes, old values persist in the db as if no update or insert occurred.
> The
> > > browser always has my latest changes.
> > >
> > > Hope that helps with your diagnosis.
> > >
> > > Jonathan.
> > >
> > > -----Original Message-----
> > > From: abishop@saucontech.com [mailto:abishop@saucontech.com]
> > > Sent: Tuesday, June 18, 2002 9:01 AM
> > > To: japple-dev@japple.org
> > > Subject: Re: [japple-dev] PostGreSQL update/insert not working??
> > >
> > >
> > >
> > >
> > > If your trace file looks OK, and includes the correct substituted
> values,
> > > then
> > > your statement should be OK.
> > > Are you using the latest jdbc driver?
> > > How is the statement being called? (dataprofile, transaction...etc)
> > > You say the database doesn't have the new data your browser has... Do
> old
> > > values
> > > persist in the database, as if no update occurred?
> > >
> > > -Adam Bishop
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > "Lonon, Jonathan B" <Jonathan.B.Lonon@bankofamerica.com> on 06/17/2002
> > > 06:09:28
> > > PM
> > >
> > > Please respond to japple-dev@japple.org
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >  To:      "'japple-tutorial@japple.org'"
> > >           <japple-tutorial@japple.org>
> > >
> > >  cc:      "'japple-dev@japple.org'"
> > >           <japple-dev@japple.org>(bcc: Adam Bishop/Saucon
> > >           Technologies)
> > >
> > >
> > >
> > >  Subject: [japple-dev] PostGreSQL update/insert not working??
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > How do I get the update and insert to work in the tutorial?  The Select
> to
> > > my PostGreSQL database works fine and the trace in the guest file looks
> > > great even for the update and insert.  However, the database does not
> have
> > > the same "new" data that my browser contains.  I think it's something
> I'm
> > > not understanding about the source and target accessors, but I'm not
> sure.
> > >
> > > Can someone point me in the right direction?  This tool appears to be
> able
> > > to help me a great deal and was very easy to grasp in general.
> > >
> > > Thanks!
> > > Jonathan.
> > > _______________________________________________
> > > japple-dev mailing list
> > > japple-dev@japple.org
> > > http://www.japple.org/mailman/listinfo/japple-dev
> > >
> > >
> > >
> > > _______________________________________________
> > > japple-dev mailing list
> > > japple-dev@japple.org
> > > http://www.japple.org/mailman/listinfo/japple-dev
> > > _______________________________________________
> > > japple-dev mailing list
> > > japple-dev@japple.org
> > > http://www.japple.org/mailman/listinfo/japple-dev
> > >
> >
> > _______________________________________________
> > japple-dev mailing list
> > japple-dev@japple.org
> > http://www.japple.org/mailman/listinfo/japple-dev
> > _______________________________________________
> > japple-dev mailing list
> > japple-dev@japple.org
> > http://www.japple.org/mailman/listinfo/japple-dev
> >
> >
> >
> > _______________________________________________
> > japple-dev mailing list
> > japple-dev@japple.org
> > http://www.japple.org/mailman/listinfo/japple-dev
> > _______________________________________________
> > japple-dev mailing list
> > japple-dev@japple.org
> > http://www.japple.org/mailman/listinfo/japple-dev
> >
> _______________________________________________
> japple-dev mailing list
> japple-dev@japple.org
> http://www.japple.org/mailman/listinfo/japple-dev
> 
> 
> 
> _______________________________________________
> japple-dev mailing list
> japple-dev@japple.org
> http://www.japple.org/mailman/listinfo/japple-dev
> _______________________________________________
> japple-dev mailing list
> japple-dev@japple.org
> http://www.japple.org/mailman/listinfo/japple-dev
> 


_______________________________________________
japple-dev mailing list
japple-dev@japple.org
http://www.japple.org/mailman/listinfo/japple-dev
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic