mode-controller: list, detail, split ...

Help
giluka
2013-05-21
2013-06-03
  • giluka
    giluka
    2013-05-21

    Hi all,
    in specifying mode-controller there is a possibility to have a different mode-controller ?
    I want to obtain a view in which after click on a row of a list in tabular mode it is show a modal dialog that contains all editable field of a specified view.

    Thanks !!

     
  • Javier Paniza
    Javier Paniza
    2013-05-23

    Hi Giluka,

    in specifying mode-controller there is a possibility to have a different mode-controller ?

    Of course, you can. Indeed, there are several already ready mode controllers available and you can create your own one.

    I want to obtain a view in which after click on a row of a list in tabular
    mode it is show a modal dialog that contains all editable field of a
    specified view.

    For that, you do not need a custom mode-controller, instead you have to define a XAVA_LIST_ACTION in your module definition. You have an example of using XAVA_LIST_ACTION in the wiki.


    Help others in this forum as I help you.
    Need more help? Get OpenXava professional support.

     
    • giluka
      giluka
      2013-05-27

      Thanks Javier,
      but if i want to show a modal dialog that contains all editable field of a
      specified row of a table ?

      Thanks

       
  • giluka
    giluka
    2013-05-27

    Hi Javier,
    i've found documentation to create editable field by a dialog box, but i've a problem now.
    I'm able to show a dialog box with editable fields populated with correct actual values ... but when i click on 'save' button new values setted are not commited into db...
    My Code:

    <controller name="EditKPI">
    <action name="editKpiValue" class="it.jlr.kpi.actions.EditItemKPIAction"/>
    <action name="updateKpiValue" class="it.jlr.kpi.actions.SaveItemKPIAction"/> </controller>

    ...
    public class EditItemKPIAction extends CollectionElementViewBaseAction {

    private int row;
    
    @Inject
    private Tab tab;
    
    public void execute() throws Exception {
        BigDecimal kpiValue=(BigDecimal)tab.getTableModel().getValueAt(this.row, COL_ID);
            getCollectionElementView().setValue("valoreKpi", kpiValue);
        showDialog(getCollectionElementView());     
        addActions("EditKPI.updateKpiValue");
        addActions(getCollectionElementView().getHideCollectionElementAction());
    }
    
    public int getRow() {
        return row;
    }
    
    public void setRow(int row) { 
        this.row = row;
    }
    
    public Tab getTab() {
        return tab;
    }
    
    public void setTab(Tab tab) {
        this.tab = tab;
    }
    

    }

    ...

    public class SaveItemKPIAction extends CollectionElementViewBaseAction {

    public void execute() throws Exception {
            String valoreKpi = getView().getValueString("valoreKpi");      
            View previousView = getPreviousView();
            previousView.setValue("valoreKpi", valoreKpi.trim());
            // here i put NEW values into previous view ... right ?
            getView().setValue("valoreKpi", valoreKpi.trim());
    
            closeDialog();
        }
    

    }

     
  • Javier Paniza
    Javier Paniza
    2013-05-29

    Hi Giluka,

    really I don't understand your goal well.

    If you want to do it with a collection element, why is not the default behavior good for you?
    If you want to show the dialog in the main list, you can just add the action "CRUD.save" as the action of the dialog.


    Help others in this forum as I help you.
    Need more help? Get OpenXava professional support.

     
  • giluka
    giluka
    2013-05-30

    You've right ... CRUD.save it's ok, but ...

    In executing save method i've an error in org.openxava.actions.SaveAction.execute in
    catch (ObjectNotFoundException ex) {
    addError("no_modify_no_exists");
    }

    i don't understand how i can set KeyEditable/editable method in my EditItemKPIAction ...

     
  • giluka
    giluka
    2013-05-30

    Hi Javier,
    now i understand !! :)

    in my edit action:

    public void execute() throws Exception {

    // show dialog modal
    showDialog(getView());
    getView().setTitleId("edit_valoreKPI");
    
    // retrieve id of selected row item
    Map rowObject=(Map)tab.getTableModel().getObjectAt(row);
    Long id=(Long) rowObject.get("id_kpi");
    
    // find current object to topulate view
    Map key = new HashMap<String, Integer>();
    key.put("id_kpi", id);
    getView().setValues(key);
    getView().findObject();
    getView().setKeyEditable(false);
    getView().setEditable(true);
    
    addActions("CRUD.save");        
    addActions(getCollectionElementView().getHideCollectionElementAction());
    

    }

    It seems works.
    It is correct ??

    Thanks !!

    p.s.:
    your framework is very good !!

     
    Last edit: giluka 2013-05-30
  • Javier Paniza
    Javier Paniza
    2013-06-03

    Hi Giluka,

    It is correct ??

    Of course, it is.
    This is programming, there is not "a correct way" to do some specific thing. Indeed, it is a fact that if the same programmer has to solve the same problem twice, he would write it in a different way.


    Help others in this forum as I help you.
    Need more help? Get OpenXava professional support.