2 Replies Latest reply on Jun 28, 2010 7:32 AM by Mike Peterson

    simple insert row without the generated forms

    adnan.m

      Hello,

       

      Is there a way to simply insert a row in a table without using the auto generated form from LCDS.

       

      I am already inserting data in one table thru the generated form, but I would like to add a row in my LOG table as well.

       

      If you can point me to a tutorial/example.

       

      Regards,

      Adnan

        • 1. Re: simple insert row without the generated forms
          AnilKrc

          I am not sure I understand your question.

           

          With Model Driven Development, the modeler generates a service for each entity e.g. the tool generates CustomerService, with CRUD methods, for the entity Customer. You are free to call create method from Flex to insert a row to your table.

           

          Alternatively, you can also override the generated Java assembler (http://help.adobe.com/en_US/LiveCycleDataServicesES/3.1/Developing/WS4976f0ec3ef482461096f 38112701857408-8000.html)

           

          Hope this helps.

           

          Anil

          • 2. Re: simple insert row without the generated forms
            Mike Peterson

            You can definitely create a new row without using hte model-driven form. As an example, take a look at the addProductToOrder() method in following MXML component. This productsAdd MXML component is used in another MXML file (also shown below).

             

            <?xml version="1.0" encoding="utf-8"?>

            <HBox

             

             

            =xmlns="http://www.adobe.com/2006/mxml" xmlns:orders="orders.*">

             

             

            <Script>

            <![CDATA[

             

             

            import orders.Orderline;

             

            import orders.Storeorder;

             

            import orders.Product;

             

            import orders.ProductService;

             

            import orders.OrderlineService;

             

            import mx.rpc.AsyncToken;

             

            import mx.collections.ArrayCollection;

             

             

            public var dgAllOrders:DataGrid;

             

            [

            Bindable]

             

            private var productFillToken:AsyncToken;

             

            [

            Bindable]

             

            public var formToHide:HBox;

             

             

            private function addProductToOrder():void

            {

             

             

            var orderLine:Orderline = new Orderline();

            orderLine.quantity = quantOfProdToAdd.value;

            orderLine.product = (dgProducts.selectedItem

            as Product);

            orderLine.storeorder = (dgAllOrders.selectedItem

            as Storeorder);

            orderLineService.createOrderline(orderLine);

            (dgAllOrders.selectedItem

            as Storeorder).orderLines.addItem(orderLine);

            orderLineService.serviceControl.commit();

            formToHide.visible =

            false;

            }

            ]]>

             

            </Script>

            <!-- <ChannelSet id="cs">

            <RTMPChannel url="rtmp://localhost:2037"/>

            </ChannelSet>

            <orders:OrderlineService id="orderLineService" channelSet="{cs}"/>

            <orders:ProductService id="productService" channelSet="{cs}"/> -->

             

             

            <orders:OrderlineService id="orderLineService"/>

             

             

            <orders:ProductService id="productService"/>

             

             

             

            <VBox>

             

             

            <HBox>

             

             

            <Button id="btnGetProducts" label="Filter Products By Name" click="{productFillToken = productService.getByNameLike('%' + searchProductName.text + '%')}"/>

             

             

            <TextInput id="searchProductName"/>

             

             

            </HBox>

             

             

            <DataGrid id="dgProducts" dataProvider="{productFillToken.result}">

             

             

            <columns>

             

             

            <DataGridColumn dataField="productname"/>

             

             

            <DataGridColumn dataField="description"/>

             

             

            <DataGridColumn dataField="price"/>

             

             

            </columns>

             

             

            </DataGrid>

             

             

            <HBox>

             

             

            <Button id="btnAddProductToOrder" label="&lt;&lt; Add Product To Order"

            click="addProductToOrder()" enabled="

            {dgProducts.selectedItem != null}"/>

             

             

            <NumericStepper id="quantOfProdToAdd" minimum="1" maximum="100" stepSize="1" enabled="{dgProducts.selectedItem != null}"/>

             

             

            <Button label="Cancel" click="formToHide.visible = false"/>

             

             

            </HBox>

             

             

             

             

            </VBox>

            </HBox>

             

            Here's the MXML app in which the MXML component is used:

             

            <?xml version="1.0" encoding="utf-8"?>

            <Application

             

            xmlns="http://www.adobe.com/2006/mxml" backgroundColor="white" height="100%" width="100%"

            xmlns:local="

            *" creationComplete="initApp()" xmlns:orders="orders.*" xmlns:generatedForms="orders.generatedForms.*"

            xmlns:forms="

            orders.forms.*">

             

            <Script>

            <![CDATA[

             

            import orders.Storeorder;

             

            import orders.StoreorderService;

             

            import mx.rpc.AsyncToken;

             

            import mx.collections.ArrayCollection;

             

            [

            Bindable]

             

            private var productFillToken:AsyncToken;

             

            [

            Bindable]

             

            private var orderFillToken:AsyncToken;

             

            private var orderService:StoreorderService = new StoreorderService();

             

             

            private function initApp():void

            {

            orderService.serviceControl.autoCommit =

            false;

            orderFillToken = orderService.getAll();

            }

             

             

            private function complete():void

            {

            orderService.serviceControl.commit();

            }

            ]]>

             

            </Script>

             

            <orders:Storeorder id="storeorder"/>

             

             

             

            <HDividedBox width="100%" height="100%" borderColor="#FFFFFF" backgroundColor="#FFFCFC">

             

            <VBox height="50%">

             

            <Button id="btnAddProduct" label="Create New Order"

            click="(dgAllOrders.dataProvider

            as ArrayCollection).addItem(new Storeorder())"/>

             

            <DataGrid id="dgAllOrders" dataProvider="{orderFillToken.result}" height="341">

             

            <columns>

             

            <DataGridColumn dataField="ordernumber"/>

             

            <DataGridColumn dataField="shipdate"/>

             

            <DataGridColumn dataField="status"/>

             

            </columns>

             

            </DataGrid>

             

            </VBox>

             

             

            <VBox height="100%">

             

            <HBox horizontalAlign="center" width="100%" >

             

            <Label text="Locale:"/>

             

            <local:languageSwitch />

             

            </HBox>

             

            <forms:StoreorderForm height="100%" id="orderForm" valueObject="{dgAllOrders.selectedItem as Storeorder}"/>

             

             

            </VBox>

             

             

            <VBox width="250">

             

             

            <Panel height="100%" width="100%" title="Order Details" label="Order Details" backgroundColor="gray"

            visible="

            {dgAllOrders.selectedItem}" includeInLayout="{dgAllOrders.selectedItem}">

             

            <local:orderLinesDetail dgAllOrders="{dgAllOrders}" visible="{dgAllOrders.selectedItem}"

            includeInLayout="

            {dgAllOrders.selectedItem}" formToShow="{productsAddForm}" width="100%"/>

             

            </Panel>

             

            </VBox>

             

            <local:productsAdd formToHide="{productsAddForm}" id="productsAddForm" dgAllOrders="{dgAllOrders}" width="100%" visible="false"/>

             

            </HDividedBox>

             

            </Application>