You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by Kristian Lind <kl...@gmail.com> on 2013/08/15 01:25:50 UTC

FormTable.

How to use the form table without Cayenne.

I am using a form table, the user can then change the values... and click
save.
But when trying to save the changes the rowlist in empty...



private JSIFormTable optionFormTable = new JSIFormTable("optionFormTable");
 public EditProduct() {
try {
buildOptionFormTable();
} catch (NumberFormatException e) {
logger.error(e.getMessage(), e);
setRedirect(com.farheap.jsi.dashboard.pages.errors.Error.class);
return;
}
}

@Override
public void onInit() {
ClickUtils.bind(form);
super.onInit();
}

@SuppressWarnings("unchecked")
private void init(final Long productId) throws SystemException {
productOptionDataProvider = new PagingDataProvider() {
@Override
public int size() {
Integer size = 0;
try {
size =
Integer.parseInt(dashboardSBBeanLocal.getProductOptionCount(productId).toString());
} catch (SystemException e) {
logger.error(e.getMessage(), e);
setRedirect(com.farheap.jsi.dashboard.pages.errors.Error.class);
}
return size;
}

@Override
public List<ProductOptionEnt> getData() {
List<ProductOptionEnt> productOptions = null;
int start = optionFormTable.getFirstRow();
int count = optionFormTable.getPageSize();
String sortColumn = optionFormTable.getSortedColumn();
if (StringUtils.isBlank(sortColumn)) {
sortColumn = "id";
}
boolean ascending = optionFormTable.isSortedAscending();
try {
//Long id =
Long.parseLong(optionFormTable.getControlLink().getParameter("productId"));
productOptions = dashboardSBBeanLocal.getProductOptions(productId, start,
count, sortColumn, ascending);
} catch (SystemException e) {
logger.error(e.getMessage(), e);
setRedirect(com.farheap.jsi.dashboard.pages.errors.Error.class);
}
return productOptions;
}
};
optionFormTable.setDataProvider(productOptionDataProvider);

}

public boolean onSaveOptionFormTable() throws SystemException {
if (optionFormTable.getForm().isValid()) {
List<ProductOptionEnt> productOptions = optionFormTable.getRowList();
dashboardSBBeanLocal.saveProductOptions(productOptions);
}
Long id = Long.parseLong(idField2.getValue());
HashMap<String, String> m = new HashMap<String, String>();
m.put("productId", "" + id);
setRedirect(CopyOfEditProduct.class, m);
return true;
}

private void buildOptionFormTable() {
optionFormTable.getForm().setButtonAlign(Form.ALIGN_RIGHT);
optionFormTable.setClass(Table.CLASS_ITS);
optionFormTable.setPageSize(Constants.MAX_PAGE_SIZE);
optionFormTable.setSortable(true);
optionFormTable.addStyleClass("dash_table80center");
optionFormTable.addColumn(new Column("id", "id"));
optionFormTable.addColumn(new Column("optionType", "Options"));

JSIOptionValueSelect select = new JSIOptionValueSelect();
select.setDependentFieldName("optionType");
Column column = new FieldColumn("value", "Value", select);
optionFormTable.addColumn(column);

RegexField basePrice = new RegexField();
basePrice.setPattern(PRICE_REGEX);
basePrice.setTextAlign("right");
column = new FieldColumn("basePrice", basePrice);
//column.setTextAlign("right");
optionFormTable.addColumn(column);

RegexField unitPrice = new RegexField();
unitPrice.setPattern(PRICE_REGEX);
unitPrice.setTextAlign("right");
column = new FieldColumn("unitPrice", unitPrice);
optionFormTable.addColumn(column);

optionFormTable.setPaginator(new TableInlinePaginator(optionFormTable));
optionFormTable.setPaginatorAttachment(Table.PAGINATOR_INLINE);

optionFormTable.setTableButtonClass("jsi_form_table_buttons");
Button button = new Submit("save", "Save", this, "onSaveOptionFormTable");
button.addStyleClass("btn btn-primary");
optionFormTable.getForm().add(button);
optionFormTable.getForm().add(idField2);

Label label = new Label("label", "Product Options");
label.addStyleClass("");
addControl(optionFormTable);

}

Re: Advice on using/extending ExcelExporter

Posted by Ernesto Celis <ce...@yahoo.es>.

De: Tim Colson <ti...@me.com>

Para: user@click.apache.org 
>Enviado: Viernes, 23 de agosto, 2013 6:31:15
>Asunto: Advice on using/extending ExcelExporter
> 
>
>
>Hi everyone -- 
>
>
>We've built a Click app for Confluence wiki management, and we want to give users an Excel export of a data table filled with metadata for wiki pages in for a specific Confluence space key. I googled and was happily surprised to find the Excel Export example for Apache Click. Woot!
>(http://click.avoka.com/click-examples/general/excel-table-export.htm)
>
>
>Looked easy enough, but the developer realized TableExporter was part of the examples package, and needs additional supporting classes and properties files, so he tried copying into our project, but ran into problems. 
>
>
>
>Have you looked at the source code for the examples? It is 
available when you get click from svn, I see many properties files 
included along with supporting classes needed for the examples to work.
>
>I'm sorry but currently I'm too busy to look closely myself, maybe later since this could be useful to me sometime.
>
>
>
>
>1) TableExportContainer.renderExportBanner() 
>-- Provides the link to the report, but is failing to load the properties file, is there some configuration that might need to be done?
>
>
>2) Link with arguments
>As a hack around #1, I replaced the banner code with a hard-coded MessageFormat.format("<span class=\"{0}\">Export options: [{1}]</span>", args);
>-- The link does not include the original URL parameter for SPACKEY which is needed to load the pages for a particular space from the DB.
>-- Looks like we need to try exportTable.setExportLink( ) to embed the params in the URL? Setup an ActionLink? PageLink? Need to create a new method to get the data? Confused here.
>
>3) Best way to Leverage the ExcelExporter classes
>The classes are doing a lot of heavy lifting with POI, but copying them seems like a bad idea long term. Suggestions?
>
>
>-Tim
>
>
>
>
>
>
> 
>
>

Re: Advice on using/extending ExcelExporter

Posted by Tim Colson <ti...@me.com>.
Thanks, Bob for the help. 
I created a click-control.properties file and it works as a quick workaround for the banner mesg, and setting a param on the exportLink fixed problem #2. 
 
 AbstractLink exportLink = exporter.getExportLink();
        exportLink.setParameter("server", server);

You were correct that the ExcelExporter example does need some tweaks, for things like Date formatting, but it mostly just works, which is a great feature. 
If we continue to enhance it, perhaps we can find time to contribute an "extras" packaged version, if that would be seen as useful?

FYI - when I searched for "click extra" - the top hit goes to sourceforge.net ( http://click.sourceforge.net/docs/extras-api/) , from there, I tried drilling into "Deploying Custom Resources" which errors out. Going up to "http://click.sourceforge.net", I just barely noticed the "Important notice" banner mentioning the new home. I think clearing out the entire sourceforge site, except for a home page with a redirect banner, would make it easier for Google and people to find the latest info.

-Tim

Re: Advice on using/extending ExcelExporter

Posted by Bob Schellink <sa...@gmail.com>.
Hi Tim,

On 2013/08/23 13:31, Tim Colson wrote:
> Hi everyone --
>
> We've built a Click app for Confluence wiki management, and we want to give users an Excel export 
> of a data table filled with metadata for wiki pages in for a specific Confluence space key. I 
> googled and was happily surprised to find the Excel Export example for Apache Click. Woot!
> (http://click.avoka.com/click-examples/general/excel-table-export.htm)
>
> Looked easy enough, but the developer realized TableExporter was part of the examples package, and 
> needs additional supporting classes and properties files, so he tried copying into our project, 
> but ran into problems.
>
> 1) TableExportContainer.renderExportBanner()
> -- Provides the link to the report, but is failing to load the properties file, is there some 
> configuration that might need to be done?

Not really. Just copy the entire folder into your project, including the property files. If you 
rename the class you should also rename the property file.
Here is how Click resolves properties:

http://click.apache.org/docs/user-guide/html/ch03s04.html#message-resolution


> 2) Link with arguments
> As a hack around #1, I replaced the banner code with a hard-coded MessageFormat.format("<span 
> class=\"{0}\">Export options: [{1}]</span>", args);
> -- The link does not include the original URL parameter for SPACKEY which is needed to load the 
> pages for a particular space from the DB.
> -- Looks like we need to try exportTable.setExportLink( ) to embed the params in the URL? Setup an 
> ActionLink? PageLink? Need to create a new method to get the data? Confused here.

     Not sure really. setExportLink sounds like it could work.

> 3) Best way to Leverage the ExcelExporter classes
> The classes are doing a lot of heavy lifting with POI, but copying them seems like a bad idea long 
> term. Suggestions?

I would just copy them into the project and adjust them to your needs. The example tries to show how 
to integrate with POI, but probably won't cover all scenarios that you would need especially when 
converting Java into Excel types. This method might need tweaking:

ExcelTableExporter#setCellValue(Object o, HSSFCell cell);

Kind regards

Bob


Advice on using/extending ExcelExporter

Posted by Tim Colson <ti...@me.com>.
Hi everyone -- 

We've built a Click app for Confluence wiki management, and we want to give users an Excel export of a data table filled with metadata for wiki pages in for a specific Confluence space key. I googled and was happily surprised to find the Excel Export example for Apache Click. Woot!
(http://click.avoka.com/click-examples/general/excel-table-export.htm)

Looked easy enough, but the developer realized TableExporter was part of the examples package, and needs additional supporting classes and properties files, so he tried copying into our project, but ran into problems. 

1) TableExportContainer.renderExportBanner() 
-- Provides the link to the report, but is failing to load the properties file, is there some configuration that might need to be done?

2) Link with arguments
As a hack around #1, I replaced the banner code with a hard-coded MessageFormat.format("<span class=\"{0}\">Export options: [{1}]</span>", args);
-- The link does not include the original URL parameter for SPACKEY which is needed to load the pages for a particular space from the DB.
-- Looks like we need to try exportTable.setExportLink( ) to embed the params in the URL? Setup an ActionLink? PageLink? Need to create a new method to get the data? Confused here.

3) Best way to Leverage the ExcelExporter classes
The classes are doing a lot of heavy lifting with POI, but copying them seems like a bad idea long term. Suggestions?

-Tim



 

Re: FormTable.

Posted by Kristian Lind <kl...@gmail.com>.
My save method looks like this.... but the productoptions list is empty.


public boolean onSaveOptionFormTable() throws SystemException {
if (optionFormTable.getForm().isValid()) {
List<ProductOptionEnt> productOptions = optionFormTable.getRowList();
dashboardSBBeanLocal.saveProductOptions(productOptions);
}
Long id = Long.parseLong(idField2.getValue());
HashMap<String, String> m = new HashMap<String, String>();
m.put("productId", "" + id);
setRedirect(EditProduct.class, m);
return true;
}


On Fri, Aug 16, 2013 at 8:42 AM, Bob Schellink <sa...@gmail.com> wrote:

>  Hibernate has a session which is equivalent to Cayenne's DataContext. So
> you need to save the changes made in the session eg:
>
> session.save(user);
> session.flush();
>
> regards
>
> Bob
>
>
> On 2013/08/15 18:41, Kristian Lind wrote:
>
> Ya, but I do not use cayenne.. on the server I use Hibernate ( JBoss )
> The client ( Click ) java code, calls a SessionBean that handles all the
> CRUD.
>
>  So I do not have the
>
> BaseContext.getThreadObjectContext().commitChanges();
>
>
> So when I click my save button, a server roundtrip is made and then the method onSaveOptionFormTable is executed, but now the optionFormTable.getRowList() returns an empty list and my changes are lost.
>
>
>
>
> On Thu, Aug 15, 2013 at 1:19 AM, Bob Schellink <sa...@gmail.com> wrote:
>
>>  Doesn't this example use FormTable and Cayenne?
>> http://click.avoka.com/click-examples/table/edit-form-table.htm
>>
>>  Perhaps you can find some ideas there on how to make FormTables work.
>>
>> regards
>>
>>  Bob
>>
>>
>> On Thu, Aug 15, 2013 at 1:25 AM, Kristian Lind <kl...@gmail.com> wrote:
>>
>>>  How to use the form table without Cayenne.
>>>
>>>  I am using a form table, the user can then change the values... and
>>> click save.
>>> But when trying to save the changes the rowlist in empty...
>>>
>>>
>>>
>>>  private JSIFormTable optionFormTable = new
>>> JSIFormTable("optionFormTable");
>>>   public EditProduct() {
>>>  try {
>>>  buildOptionFormTable();
>>>  } catch (NumberFormatException e) {
>>>  logger.error(e.getMessage(), e);
>>>  setRedirect(com.farheap.jsi.dashboard.pages.errors.Error.class);
>>>  return;
>>>  }
>>>  }
>>>
>>>  @Override
>>>  public void onInit() {
>>>  ClickUtils.bind(form);
>>>  super.onInit();
>>>  }
>>>
>>>  @SuppressWarnings("unchecked")
>>>  private void init(final Long productId) throws SystemException {
>>>  productOptionDataProvider = new PagingDataProvider() {
>>>  @Override
>>>  public int size() {
>>>  Integer size = 0;
>>>  try {
>>>  size =
>>> Integer.parseInt(dashboardSBBeanLocal.getProductOptionCount(productId).toString());
>>>  } catch (SystemException e) {
>>>  logger.error(e.getMessage(), e);
>>>  setRedirect(com.farheap.jsi.dashboard.pages.errors.Error.class);
>>>  }
>>>  return size;
>>>  }
>>>
>>>  @Override
>>>  public List<ProductOptionEnt> getData() {
>>>  List<ProductOptionEnt> productOptions = null;
>>>  int start = optionFormTable.getFirstRow();
>>>  int count = optionFormTable.getPageSize();
>>>  String sortColumn = optionFormTable.getSortedColumn();
>>>  if (StringUtils.isBlank(sortColumn)) {
>>>  sortColumn = "id";
>>>  }
>>>  boolean ascending = optionFormTable.isSortedAscending();
>>>  try {
>>>  //Long id =
>>> Long.parseLong(optionFormTable.getControlLink().getParameter("productId"));
>>>  productOptions = dashboardSBBeanLocal.getProductOptions(productId,
>>> start, count, sortColumn, ascending);
>>>  } catch (SystemException e) {
>>>  logger.error(e.getMessage(), e);
>>>  setRedirect(com.farheap.jsi.dashboard.pages.errors.Error.class);
>>>  }
>>>  return productOptions;
>>>  }
>>>  };
>>>  optionFormTable.setDataProvider(productOptionDataProvider);
>>>
>>>  }
>>>
>>>  public boolean onSaveOptionFormTable() throws SystemException {
>>>  if (optionFormTable.getForm().isValid()) {
>>>  List<ProductOptionEnt> productOptions = optionFormTable.getRowList();
>>>  dashboardSBBeanLocal.saveProductOptions(productOptions);
>>>  }
>>>  Long id = Long.parseLong(idField2.getValue());
>>>  HashMap<String, String> m = new HashMap<String, String>();
>>>  m.put("productId", "" + id);
>>>  setRedirect(CopyOfEditProduct.class, m);
>>>  return true;
>>>  }
>>>
>>>  private void buildOptionFormTable() {
>>>  optionFormTable.getForm().setButtonAlign(Form.ALIGN_RIGHT);
>>>  optionFormTable.setClass(Table.CLASS_ITS);
>>>  optionFormTable.setPageSize(Constants.MAX_PAGE_SIZE);
>>>  optionFormTable.setSortable(true);
>>>  optionFormTable.addStyleClass("dash_table80center");
>>>  optionFormTable.addColumn(new Column("id", "id"));
>>>  optionFormTable.addColumn(new Column("optionType", "Options"));
>>>
>>>  JSIOptionValueSelect select = new JSIOptionValueSelect();
>>>  select.setDependentFieldName("optionType");
>>>  Column column = new FieldColumn("value", "Value", select);
>>>  optionFormTable.addColumn(column);
>>>
>>>  RegexField basePrice = new RegexField();
>>>  basePrice.setPattern(PRICE_REGEX);
>>>  basePrice.setTextAlign("right");
>>>  column = new FieldColumn("basePrice", basePrice);
>>>  //column.setTextAlign("right");
>>>  optionFormTable.addColumn(column);
>>>
>>>  RegexField unitPrice = new RegexField();
>>>  unitPrice.setPattern(PRICE_REGEX);
>>>  unitPrice.setTextAlign("right");
>>>  column = new FieldColumn("unitPrice", unitPrice);
>>>  optionFormTable.addColumn(column);
>>>
>>>  optionFormTable.setPaginator(new
>>> TableInlinePaginator(optionFormTable));
>>>  optionFormTable.setPaginatorAttachment(Table.PAGINATOR_INLINE);
>>>
>>>  optionFormTable.setTableButtonClass("jsi_form_table_buttons");
>>>  Button button = new Submit("save", "Save", this,
>>> "onSaveOptionFormTable");
>>>  button.addStyleClass("btn btn-primary");
>>>  optionFormTable.getForm().add(button);
>>>  optionFormTable.getForm().add(idField2);
>>>
>>>  Label label = new Label("label", "Product Options");
>>>  label.addStyleClass("");
>>>  addControl(optionFormTable);
>>>
>>>  }
>>>
>>>
>>>
>>>
>>>
>>>
>>
>
>
>  --
> Best regards
>
> Kristian Lind
>
>
>


-- 
Best regards

Kristian Lind

Re: FormTable.

Posted by Bob Schellink <sa...@gmail.com>.
Hibernate has a session which is equivalent to Cayenne's DataContext. So you need to save the 
changes made in the session eg:

session.save(user);
session.flush();

regards

Bob

On 2013/08/15 18:41, Kristian Lind wrote:
> Ya, but I do not use cayenne.. on the server I use Hibernate ( JBoss )
> The client ( Click ) java code, calls a SessionBean that handles all the CRUD.
>
> So I do not have the
> BaseContext.getThreadObjectContext().commitChanges();
> So when I click my save button, a server roundtrip is made and then the method 
> onSaveOptionFormTable is executed, but now the optionFormTable.getRowList() returns an empty list 
> and my changes are lost.
>
>
>
>
> On Thu, Aug 15, 2013 at 1:19 AM, Bob Schellink <sabob1@gmail.com <ma...@gmail.com>> wrote:
>
>     Doesn't this example use FormTable and Cayenne?
>     http://click.avoka.com/click-examples/table/edit-form-table.htm
>
>     Perhaps you can find some ideas there on how to make FormTables work.
>
>     regards
>
>     Bob
>
>
>     On Thu, Aug 15, 2013 at 1:25 AM, Kristian Lind <klindp@gmail.com <ma...@gmail.com>> wrote:
>
>         How to use the form table without Cayenne.
>
>         I am using a form table, the user can then change the values... and click save.
>         But when trying to save the changes the rowlist in empty...
>
>
>
>         private JSIFormTable optionFormTable = new JSIFormTable("optionFormTable");
>         public EditProduct() {
>         try {
>         buildOptionFormTable();
>         } catch (NumberFormatException e) {
>         logger.error(e.getMessage(), e);
>         setRedirect(com.farheap.jsi.dashboard.pages.errors.Error.class);
>         return;
>         }
>         }
>
>         @Override
>         public void onInit() {
>         ClickUtils.bind(form);
>         super.onInit();
>         }
>
>         @SuppressWarnings("unchecked")
>         private void init(final Long productId) throws SystemException {
>         productOptionDataProvider = new PagingDataProvider() {
>         @Override
>         public int size() {
>         Integer size = 0;
>         try {
>         size = Integer.parseInt(dashboardSBBeanLocal.getProductOptionCount(productId).toString());
>         } catch (SystemException e) {
>         logger.error(e.getMessage(), e);
>         setRedirect(com.farheap.jsi.dashboard.pages.errors.Error.class);
>         }
>         return size;
>         }
>
>         @Override
>         public List<ProductOptionEnt> getData() {
>         List<ProductOptionEnt> productOptions = null;
>         int start = optionFormTable.getFirstRow();
>         int count = optionFormTable.getPageSize();
>         String sortColumn = optionFormTable.getSortedColumn();
>         if (StringUtils.isBlank(sortColumn)) {
>         sortColumn = "id";
>         }
>         boolean ascending = optionFormTable.isSortedAscending();
>         try {
>         //Long id = Long.parseLong(optionFormTable.getControlLink().getParameter("productId"));
>         productOptions = dashboardSBBeanLocal.getProductOptions(productId, start, count,
>         sortColumn, ascending);
>         } catch (SystemException e) {
>         logger.error(e.getMessage(), e);
>         setRedirect(com.farheap.jsi.dashboard.pages.errors.Error.class);
>         }
>         return productOptions;
>         }
>         };
>         optionFormTable.setDataProvider(productOptionDataProvider);
>
>         }
>
>         public boolean onSaveOptionFormTable() throws SystemException {
>         if (optionFormTable.getForm().isValid()) {
>         List<ProductOptionEnt> productOptions = optionFormTable.getRowList();
>         dashboardSBBeanLocal.saveProductOptions(productOptions);
>         }
>         Long id = Long.parseLong(idField2.getValue());
>         HashMap<String, String> m = new HashMap<String, String>();
>         m.put("productId", "" + id);
>         setRedirect(CopyOfEditProduct.class, m);
>         return true;
>         }
>
>         private void buildOptionFormTable() {
>         optionFormTable.getForm().setButtonAlign(Form.ALIGN_RIGHT);
>         optionFormTable.setClass(Table.CLASS_ITS);
>         optionFormTable.setPageSize(Constants.MAX_PAGE_SIZE);
>         optionFormTable.setSortable(true);
>         optionFormTable.addStyleClass("dash_table80center");
>         optionFormTable.addColumn(new Column("id", "id"));
>         optionFormTable.addColumn(new Column("optionType", "Options"));
>
>         JSIOptionValueSelect select = new JSIOptionValueSelect();
>         select.setDependentFieldName("optionType");
>         Column column = new FieldColumn("value", "Value", select);
>         optionFormTable.addColumn(column);
>
>         RegexField basePrice = new RegexField();
>         basePrice.setPattern(PRICE_REGEX);
>         basePrice.setTextAlign("right");
>         column = new FieldColumn("basePrice", basePrice);
>         //column.setTextAlign("right");
>         optionFormTable.addColumn(column);
>
>         RegexField unitPrice = new RegexField();
>         unitPrice.setPattern(PRICE_REGEX);
>         unitPrice.setTextAlign("right");
>         column = new FieldColumn("unitPrice", unitPrice);
>         optionFormTable.addColumn(column);
>
>         optionFormTable.setPaginator(new TableInlinePaginator(optionFormTable));
>         optionFormTable.setPaginatorAttachment(Table.PAGINATOR_INLINE);
>
>         optionFormTable.setTableButtonClass("jsi_form_table_buttons");
>         Button button = new Submit("save", "Save", this, "onSaveOptionFormTable");
>         button.addStyleClass("btn btn-primary");
>         optionFormTable.getForm().add(button);
>         optionFormTable.getForm().add(idField2);
>
>         Label label = new Label("label", "Product Options");
>         label.addStyleClass("");
>         addControl(optionFormTable);
>
>         }
>
>
>
>
>
>
>
>
>
> -- 
> Best regards
>
> Kristian Lind


Re: FormTable.

Posted by Kristian Lind <kl...@gmail.com>.
Ya, but I do not use cayenne.. on the server I use Hibernate ( JBoss )
The client ( Click ) java code, calls a SessionBean that handles all the
CRUD.

So I do not have the

BaseContext.getThreadObjectContext().commitChanges();

So when I click my save button, a server roundtrip is made and then
the method onSaveOptionFormTable is executed, but now the
optionFormTable.getRowList() returns an empty list and my changes are
lost.




On Thu, Aug 15, 2013 at 1:19 AM, Bob Schellink <sa...@gmail.com> wrote:

> Doesn't this example use FormTable and Cayenne?
> http://click.avoka.com/click-examples/table/edit-form-table.htm
>
> Perhaps you can find some ideas there on how to make FormTables work.
>
> regards
>
> Bob
>
>
> On Thu, Aug 15, 2013 at 1:25 AM, Kristian Lind <kl...@gmail.com> wrote:
>
>> How to use the form table without Cayenne.
>>
>> I am using a form table, the user can then change the values... and click
>> save.
>> But when trying to save the changes the rowlist in empty...
>>
>>
>>
>> private JSIFormTable optionFormTable = new
>> JSIFormTable("optionFormTable");
>>  public EditProduct() {
>> try {
>> buildOptionFormTable();
>>  } catch (NumberFormatException e) {
>> logger.error(e.getMessage(), e);
>> setRedirect(com.farheap.jsi.dashboard.pages.errors.Error.class);
>>  return;
>> }
>> }
>>
>> @Override
>>  public void onInit() {
>> ClickUtils.bind(form);
>> super.onInit();
>>  }
>>
>> @SuppressWarnings("unchecked")
>> private void init(final Long productId) throws SystemException {
>>  productOptionDataProvider = new PagingDataProvider() {
>> @Override
>> public int size() {
>>  Integer size = 0;
>> try {
>> size =
>> Integer.parseInt(dashboardSBBeanLocal.getProductOptionCount(productId).toString());
>>  } catch (SystemException e) {
>> logger.error(e.getMessage(), e);
>> setRedirect(com.farheap.jsi.dashboard.pages.errors.Error.class);
>>  }
>> return size;
>> }
>>
>> @Override
>>  public List<ProductOptionEnt> getData() {
>> List<ProductOptionEnt> productOptions = null;
>>  int start = optionFormTable.getFirstRow();
>> int count = optionFormTable.getPageSize();
>> String sortColumn = optionFormTable.getSortedColumn();
>>  if (StringUtils.isBlank(sortColumn)) {
>> sortColumn = "id";
>> }
>>  boolean ascending = optionFormTable.isSortedAscending();
>> try {
>> //Long id =
>> Long.parseLong(optionFormTable.getControlLink().getParameter("productId"));
>>  productOptions = dashboardSBBeanLocal.getProductOptions(productId,
>> start, count, sortColumn, ascending);
>> } catch (SystemException e) {
>>  logger.error(e.getMessage(), e);
>> setRedirect(com.farheap.jsi.dashboard.pages.errors.Error.class);
>>  }
>> return productOptions;
>> }
>> };
>>  optionFormTable.setDataProvider(productOptionDataProvider);
>>
>> }
>>
>> public boolean onSaveOptionFormTable() throws SystemException {
>>  if (optionFormTable.getForm().isValid()) {
>> List<ProductOptionEnt> productOptions = optionFormTable.getRowList();
>>  dashboardSBBeanLocal.saveProductOptions(productOptions);
>> }
>> Long id = Long.parseLong(idField2.getValue());
>>  HashMap<String, String> m = new HashMap<String, String>();
>> m.put("productId", "" + id);
>>  setRedirect(CopyOfEditProduct.class, m);
>> return true;
>> }
>>
>> private void buildOptionFormTable() {
>> optionFormTable.getForm().setButtonAlign(Form.ALIGN_RIGHT);
>>  optionFormTable.setClass(Table.CLASS_ITS);
>> optionFormTable.setPageSize(Constants.MAX_PAGE_SIZE);
>> optionFormTable.setSortable(true);
>>  optionFormTable.addStyleClass("dash_table80center");
>> optionFormTable.addColumn(new Column("id", "id"));
>>  optionFormTable.addColumn(new Column("optionType", "Options"));
>>
>> JSIOptionValueSelect select = new JSIOptionValueSelect();
>>  select.setDependentFieldName("optionType");
>> Column column = new FieldColumn("value", "Value", select);
>>  optionFormTable.addColumn(column);
>>
>> RegexField basePrice = new RegexField();
>> basePrice.setPattern(PRICE_REGEX);
>>  basePrice.setTextAlign("right");
>> column = new FieldColumn("basePrice", basePrice);
>>  //column.setTextAlign("right");
>> optionFormTable.addColumn(column);
>>
>> RegexField unitPrice = new RegexField();
>>  unitPrice.setPattern(PRICE_REGEX);
>> unitPrice.setTextAlign("right");
>> column = new FieldColumn("unitPrice", unitPrice);
>>  optionFormTable.addColumn(column);
>>
>> optionFormTable.setPaginator(new TableInlinePaginator(optionFormTable));
>>  optionFormTable.setPaginatorAttachment(Table.PAGINATOR_INLINE);
>>
>> optionFormTable.setTableButtonClass("jsi_form_table_buttons");
>>  Button button = new Submit("save", "Save", this,
>> "onSaveOptionFormTable");
>> button.addStyleClass("btn btn-primary");
>>  optionFormTable.getForm().add(button);
>> optionFormTable.getForm().add(idField2);
>>
>> Label label = new Label("label", "Product Options");
>>  label.addStyleClass("");
>> addControl(optionFormTable);
>>
>> }
>>
>>
>>
>>
>>
>>
>


-- 
Best regards

Kristian Lind

Re: FormTable.

Posted by Bob Schellink <sa...@gmail.com>.
Doesn't this example use FormTable and Cayenne?
http://click.avoka.com/click-examples/table/edit-form-table.htm

Perhaps you can find some ideas there on how to make FormTables work.

regards

Bob


On Thu, Aug 15, 2013 at 1:25 AM, Kristian Lind <kl...@gmail.com> wrote:

> How to use the form table without Cayenne.
>
> I am using a form table, the user can then change the values... and click
> save.
> But when trying to save the changes the rowlist in empty...
>
>
>
> private JSIFormTable optionFormTable = new JSIFormTable("optionFormTable");
>  public EditProduct() {
> try {
> buildOptionFormTable();
>  } catch (NumberFormatException e) {
> logger.error(e.getMessage(), e);
> setRedirect(com.farheap.jsi.dashboard.pages.errors.Error.class);
>  return;
> }
> }
>
> @Override
>  public void onInit() {
> ClickUtils.bind(form);
> super.onInit();
>  }
>
> @SuppressWarnings("unchecked")
> private void init(final Long productId) throws SystemException {
>  productOptionDataProvider = new PagingDataProvider() {
> @Override
> public int size() {
>  Integer size = 0;
> try {
> size =
> Integer.parseInt(dashboardSBBeanLocal.getProductOptionCount(productId).toString());
>  } catch (SystemException e) {
> logger.error(e.getMessage(), e);
> setRedirect(com.farheap.jsi.dashboard.pages.errors.Error.class);
>  }
> return size;
> }
>
> @Override
>  public List<ProductOptionEnt> getData() {
> List<ProductOptionEnt> productOptions = null;
>  int start = optionFormTable.getFirstRow();
> int count = optionFormTable.getPageSize();
> String sortColumn = optionFormTable.getSortedColumn();
>  if (StringUtils.isBlank(sortColumn)) {
> sortColumn = "id";
> }
>  boolean ascending = optionFormTable.isSortedAscending();
> try {
> //Long id =
> Long.parseLong(optionFormTable.getControlLink().getParameter("productId"));
>  productOptions = dashboardSBBeanLocal.getProductOptions(productId,
> start, count, sortColumn, ascending);
> } catch (SystemException e) {
>  logger.error(e.getMessage(), e);
> setRedirect(com.farheap.jsi.dashboard.pages.errors.Error.class);
>  }
> return productOptions;
> }
> };
>  optionFormTable.setDataProvider(productOptionDataProvider);
>
> }
>
> public boolean onSaveOptionFormTable() throws SystemException {
>  if (optionFormTable.getForm().isValid()) {
> List<ProductOptionEnt> productOptions = optionFormTable.getRowList();
>  dashboardSBBeanLocal.saveProductOptions(productOptions);
> }
> Long id = Long.parseLong(idField2.getValue());
>  HashMap<String, String> m = new HashMap<String, String>();
> m.put("productId", "" + id);
>  setRedirect(CopyOfEditProduct.class, m);
> return true;
> }
>
> private void buildOptionFormTable() {
> optionFormTable.getForm().setButtonAlign(Form.ALIGN_RIGHT);
>  optionFormTable.setClass(Table.CLASS_ITS);
> optionFormTable.setPageSize(Constants.MAX_PAGE_SIZE);
> optionFormTable.setSortable(true);
>  optionFormTable.addStyleClass("dash_table80center");
> optionFormTable.addColumn(new Column("id", "id"));
>  optionFormTable.addColumn(new Column("optionType", "Options"));
>
> JSIOptionValueSelect select = new JSIOptionValueSelect();
>  select.setDependentFieldName("optionType");
> Column column = new FieldColumn("value", "Value", select);
>  optionFormTable.addColumn(column);
>
> RegexField basePrice = new RegexField();
> basePrice.setPattern(PRICE_REGEX);
>  basePrice.setTextAlign("right");
> column = new FieldColumn("basePrice", basePrice);
>  //column.setTextAlign("right");
> optionFormTable.addColumn(column);
>
> RegexField unitPrice = new RegexField();
>  unitPrice.setPattern(PRICE_REGEX);
> unitPrice.setTextAlign("right");
> column = new FieldColumn("unitPrice", unitPrice);
>  optionFormTable.addColumn(column);
>
> optionFormTable.setPaginator(new TableInlinePaginator(optionFormTable));
>  optionFormTable.setPaginatorAttachment(Table.PAGINATOR_INLINE);
>
> optionFormTable.setTableButtonClass("jsi_form_table_buttons");
>  Button button = new Submit("save", "Save", this,
> "onSaveOptionFormTable");
> button.addStyleClass("btn btn-primary");
>  optionFormTable.getForm().add(button);
> optionFormTable.getForm().add(idField2);
>
> Label label = new Label("label", "Product Options");
>  label.addStyleClass("");
> addControl(optionFormTable);
>
> }
>
>
>
>
>
>