Saving the inputs from Jade

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Saving the inputs from Jade

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:27 pm

by Shane >> Sun, 26 Oct 2003 8:34:54 GMT

Hey

Im new to Jade and only just started teaching myself it.

I am creating a schema which is based on a sports club. I have created all my forms.... and the code which allows you fill in all the text boxes and press on the "submit player" button. I got the status bar at the bottom to display messages as well, both when all fields have been finalised and if you try to submit thr data when fields are incomplete.

Anyway...... my main problem is i cant work out how to save all this data, so that it is stored next time you open the forms. :(

Do i need to create a jadescript method which writes it to a .txt tile or something??

Any help would be much appreciated.

Thanks

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Saving the inputs from Jade

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:27 pm

by allistar >> Sun, 26 Oct 2003 21:32:36 GMT

Hi there,
You need to have a class that represents a player. You could call this "Player" if you wanted. You then need to add attributes to this class that represent the things you want to store (like "name", "phoneNumber" etc). On the form you need to create an instance of this class and set the properties on it based on what the user has entered on the form.

You may benefit from the tutorials found on the website, they will help to get a grip on how all of this works.

Regards,
Allistar.

------------------------------------------------------------------
Allistar Melville
Software Developer, Analyst allistar@silvermoon.co.nz
Auckland, NEW ZEALAND

Silvermoon Software
Specialising in JADE development and consulting
Visit us at: http://www.silvermoon.co.nz
*NEW* Simple web access to Jade at: www.silvermoon.co.nz/jhp.html ------------------------------------------------------------------

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Saving the inputs from Jade

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:27 pm

by Patwos >> Mon, 27 Oct 2003 2:36:20 GMT

As Allistar said you should take a look at the tutorials as they will help give you more insight into Jade's OO database and the ease with which you can store your persistent data.

I'd also suggest that you "have the cart before the horse" so to speak. You should really be designing the object model to store your persistent data before you start painting up the forms to present and/or capture this information.

You may also want to download and check out the Erewhon sample schema as well as work your way through the various tutorials.

Hope that helps,
Pat.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Saving the inputs from Jade

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:27 pm

by Shane >> Mon, 27 Oct 2003 3:51:40 GMT

Thanks for your help guys :)

I had already done the steps mentioned, and when i click on the 'submit player' button, and i go back to the schema to inspect the instances it shows what I have inputted.

What i meant was how do i upload this to another form called view players, say in a list box or something??

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Saving the inputs from Jade

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:27 pm

by Patwos >> Mon, 27 Oct 2003 6:58:55 GMT

I'll presume you have a class something like say Club, and you have on this a collection of all the players for that Club in a reference called say allPlayers. Let's assume for now that there is only a single club in this system and that you set app.myClub := Club.firstInstance in your application's initialise logic. You could now display all the players for that club in a "View" form using the ListBox::displayCollection method as follows - you could put this into say the Form::load event for your "View" form. This code assumes the above assumptions and that you have called your ListBox lstPlayers:

lstPlayers.displayCollection( app.myClub.allPlayers, true, Table.DisplayCollection_Forward, null, null );

You would then need to implement the lstPlayers_displayRow event method on this form to return the desired information for each entry in the lstPlayers ListBox - or if you want to suppress a given Player from the ListBox you could return null.

You could also use the older but similar ListBox::listCollection method and it's associated ListBox::displayEntry event.

Hope that helps,
Pat.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Saving the inputs from Jade

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:27 pm

by Patwos >> Mon, 27 Oct 2003 7:02:15 GMT

While it would compile and run correctly, because the constants have the same values, it would be better if you corrected the following code:

listBox1.displayCollection( app.myClub.allPlayers, true, Table.DisplayCollection_Forward, null, null );

To use the ListBox.DisplayCollection_Forward constant instead:

listBox1.displayCollection( app.myClub.allPlayers, true, ListBox.DisplayCollection_Forward, null, null );


Pat.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Saving the inputs from Jade

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:27 pm

by allistar >> Tue, 28 Oct 2003 7:35:56 GMT

IN addition to Pats excellent comments you need to set the "myClub" reference on the new Player object.

In the "set" method on the Player class you need to have this:

myClub := app.myClub;

That one line of code will put the Player object in the Club.allPlayers collection.

Regards,
Allistar.

------------------------------------------------------------------
Allistar Melville
Software Developer, Analyst allistar@silvermoon.co.nz
Auckland, NEW ZEALAND

Silvermoon Software
Specialising in JADE development and consulting
Visit us at: http://www.silvermoon.co.nz
*NEW* Simple web access to Jade at: www.silvermoon.co.nz/jhp.html ------------------------------------------------------------------


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 14 guests