Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » TableField in Form(How to access Data from Database)
TableField in Form [message #1800963] Thu, 10 January 2019 12:00 Go to next message
The Maddes is currently offline The MaddesFriend
Messages: 44
Registered: October 2018
Member
Hey guys happy new year!
New year, new questions.

So i dont get how i can get this to work.

I have a button to load a new form.
This form now needs to be an editable table.
So far so good.
What i dont get is how can i achieve that the table gets populated with (if) existing data from a database.

And i need to save the newly added rows to the database. I think this can be done with the row_state.

Maybe it is a little confusing, because to me the table belongs to the form. The form has no other fields than the tablefield. So what kind of service / dataprovider do i need to implement?
I was reading about that here:
https://wiki.eclipse.org/Scout/Concepts/TableData#Bean_based_TableData

What i dont understand is, theres an extra FormData Annotation for the table, but i dont see how to work with that data over the formhandler services.

I hope it is somehow understandable what i want to achieve.

Form with an editable table that can be stored to the database and also filled by the database.

Thank you for any kind of input!
Re: TableField in Form [message #1800964 is a reply to message #1800963] Thu, 10 January 2019 12:15 Go to previous messageGo to next message
Matthias OtterbachFriend
Messages: 29
Registered: August 2015
Location: Munich
Junior Member
So I suppose you have a form with just a TableField within the MainBox (and maybe an OkButton/CancelButton to close the form). The TableField should contain an additional Table class, e.g.:

public class MainBox extends AbstractGroupBox {
    public class MyTableField extends AbstractTableField<MyTableField.MyTableFieldTable> {
      public class MyTableFieldTable extends AbstractTable {
        // additional code with columns here..
      }
    }
}


Is there a FormData class generated for your Form? The FormData class should include a getter for the table, e.g. in my case getMyTable, with this getter you can add/set the rows of the table and use the default export/import methods on the form.
Re: TableField in Form [message #1801019 is a reply to message #1800964] Fri, 11 January 2019 09:06 Go to previous messageGo to next message
The Maddes is currently offline The MaddesFriend
Messages: 44
Registered: October 2018
Member
Hey Matthias,

you were guessing absolutely right.

So far i implemented the table and i can access it.

But i have a question regarding the Database handling.

So if i want to save x rows, it seems like i have to do sth like that:

MyTableRowData[] formRows = formData.getMyTable().getRows();
    for (MyTableRowData row : formRows) {   
      if(ITableBeanRowHolder.STATUS_INSERTED == row.getRowState()) {
        SQL.insert(SQLs.INSERT_STATEMENT
            , new NVPair("value1Formdata", formData.getValue1())
            , new NVPair("valueXFormdata", formData.getValueX())
            , new NVPair("valueXRowData" row.getValueX())
            , row);
      } 
    }


To me it seems thats not the best way to achieve the desired result.

[Updated on: Fri, 11 January 2019 09:06]

Report message to a moderator

Re: TableField in Form [message #1801026 is a reply to message #1801019] Fri, 11 January 2019 10:10 Go to previous messageGo to next message
Matthias OtterbachFriend
Messages: 29
Registered: August 2015
Location: Munich
Junior Member
I'm sorry if I misunderstood the question - unfortunately I also do not know if there is a helper/utility method for inserting the table rows in the database.
Re: TableField in Form [message #1801117 is a reply to message #1801026] Mon, 14 January 2019 08:44 Go to previous message
The Maddes is currently offline The MaddesFriend
Messages: 44
Registered: October 2018
Member
Hey Matthias,

thank you :) So i guess i will just stick to that way and build it like that, its just a little more of coding but thats no problem at all.
I was just thinking that there might be something handy im missing out on.

But anyways, thank you again for your input!
Previous Topic:Calendar in Scout Photon
Next Topic:Statusbar of a Tablepage Tabl
Goto Forum:
  


Current Time: Thu Dec 12 19:46:11 GMT 2019

Powered by FUDForum. Page generated in 0.02201 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top