gigaZhang / struts2-jquery

Automatically exported from code.google.com/p/struts2-jquery
0 stars 0 forks source link

formIds attribute not working #1075

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The formIds attribute does not appear to be working. Expect it to work similar 
to the grid component.

Which struts2 version?
struts2-core-2.3.15.1

Which struts2-jquery plugin version?
struts2-jquery-tree-plugin-3.6.1

Please provide any additional information below.

Original issue reported on code.google.com by snyd...@llnl.gov on 18 Jan 2014 at 12:05

GoogleCodeExporter commented 9 years ago
Please provide an example application or describe this issue more detailed.

Original comment by johgep on 10 Apr 2014 at 8:00

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago

We have a form to hold various id's ...

<div style="display:none">
<s:form id="binForm" action="home" method="POST">
    <s:hidden id="binId" name="binId"/>
    <s:hidden id="itemId" name="itemId"/>
    <s:hidden id="hierId" name="hierId"/>
        .
        .
        .
        .       
    <s:hidden id="anotherId" name="anotherId"/>
</s:form>
</div>

There are selectors on the page to set the "binId" and other id values.

A notional tree action execute method (return JSON data) ...

    public String execute() throws Exception {              
        log.info("binId= " + this.getBinId());

        // if the id's are NOT passed on the url, they are null in the action.

        nodeList = treenodeDAO.list(this.getBinId()); // retrieve the node list for the given bin from the database
        // code to build the TreeNode hierarchy from the flat list
        // .
        // .
        // .        

        return SUCCESS;
    }

The notional tree jsp ...

<s:url var="treeDataUrl" 
action="MY_jsonNotionalTreeAction?binId=%{binId}&anotherId=%{anotherId}&etc..."/
>
 !!! required id's are added to the url as a work-around because the formIds attribute does not work on the tree !!!

<sjt:tree 
        id="jsonNotionalTree"
        title="Node Hierarchy"
        jstreetheme="apple"
        href="%{treeDataUrl}"
        formIds="binForm"
        width="400"
        rootNode="nodes"
        selectable="true"
        onClickTopics="myRowSelect"
        onCompleteTopics="myTreeComplete"
        contextmenu="{
                      items: { 
                              'create' : false,
                              'rename' : false,
                              'ccp' : false,
                              'remove' : false,
                              'additem' : { 
                                      'label': 'Add Item', 
                                      'action':  function (obj) { myAddItem(obj); }
                              } 
                      } 
              }"

/>

A notional grid action (return JSON data) ...

    public String execute() throws Exception {              
        log.info("binId= " + this.getBinId());
        itemList = treenodeDAO.list(this.getBinId()); // retrieve the items for the given bin from the database
        // code to build the grid model from the flat list
        // .
        // .
        // .        

        return SUCCESS;
    }

The notional grid jsp ...

 <s:url var="remoteurl" action="MY_jsonNotionalGridAction"/>
 !!! required id's are not needed on the url because the formIds attribute works on the grid !!!

    <sjg:grid
        id="itemGrid"
        caption="Items"
        hiddengrid="false"
        hidegrid="false"
        dataType="json"
        href="%{remoteurl}"
        formIds="binForm" 
        gridModel="gridModel"
        loadonce="false"
        altClass="ui-altRows"
        altRows="true"
        pager="true"
        toppager="true"
        scroll="true"
        rowNum="-1"
        viewrecords="true"
        sortable="true"
        rownumbers="true"
        height="800"
        shrinkToFit="false"
        scrollrows="true"
        filter="true"
        filterOptions="{
            stringResult: true,
            defaultSearch: 'cn',
            searchOnEnter: true,
            enableClear: true
        }"
        navigator="true"
        navigatorCloneToTop="true"
        navigatorAdd="false"
        navigatorView="false"
        navigatorEdit="false"
        navigatorDelete="false"
        navigatorRefresh="true"
        navigatorSearch="true"
        navigatorSearchOptions="{
            width: 350,
            multipleSearch:true,
            reloadAfterSubmit: true         
        }"
        navigatorExtraButtons="{                                
        }"        
        onSelectRowTopics="itemRowSelect"
        onCellSelectTopics="itemCellSelect"
        onDblClickRowTopics="itemDblClick"
        onGridCompleteTopics="itemGridComplete" 
     >
        <sjg:gridColumn name="0" title="ID" key="true" hidden="true"/>
        <sjg:gridColumn name="1" title="Item Name" sortable="true" />
        <sjg:gridColumn name="2" title="Item Description" sortable="true" />
    </sjg:grid>

Original comment by snyd...@llnl.gov on 11 Apr 2014 at 10:11

GoogleCodeExporter commented 9 years ago
The component for this issue should be Tree-Plugin and not Grid-Plugin.  
Tree-Plugin is not working as expected (the formIds attribute of the tree is 
being ignored).
Grid-Plugin is working correctly (the fields of the forms referred to in the 
formIds attribute are included in the request packet for the grid).

Original comment by albist...@llnl.gov on 21 Apr 2014 at 5:36

GoogleCodeExporter commented 9 years ago
Thank you for sample. I will check out if the same solution for grid plugin 
will work for tree plugin too.

Original comment by johgep on 22 Apr 2014 at 7:18