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 <[email protected]> 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 <[email protected]> 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 <[email protected]> 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

Reply via email to