1 2 Previous Next 16 Replies Latest reply: May 6, 2013 8:25 AM by OraInfo RSS

    dynamic viewObject

    OraInfo
      hello,
      i was follow this exemple to create a dynamic view Object exemple ,but in the viewController project when i want to use this 'row.getAttribute("EMP_MAT")' to get the value of the attribute ,it told me tha the attribute EMP_MAT not exist in the view object,please can you help me.
        • 1. Re: dynamic viewObject
          Suresh Karunarathne
          HI,
          try to get
          row.getAttribute("EmpMat")// Check attributes tabs in dynamic VO for more information
          • 2. Re: dynamic viewObject
            Frank Nimphius-Oracle
            Hi,

            select * from Emp (scott/tiger) schema does not have a column EMP_MAT unless it is manually added. i think this is the problem you run into

            Frank
            • 3. Re: dynamic viewObject
              OraInfo
              it the same probleme Suresh , EmpMat oftype Attribut not exist in the viewObject
              • 4. Re: dynamic viewObject
                Manish
                you can get value of attribute using

                row.getAttribute(int index) in place of row.getAttribute("AttrName")

                like for first attribute

                row.getAttribute(0)
                • 5. Re: dynamic viewObject
                  Rajan M
                  Check your ViewObject attributes list if you have the required attribute with the name EmpMat.
                  If it is there, the code should work.

                  also can you post your viewObject source.

                  regards,
                  Rajan
                  • 6. Re: dynamic viewObject
                    OraInfo
                    Rajan M wrote:
                    Check your ViewObject attributes list if you have the required attribute with the name EmpMat.
                    If it is there, the code should work.

                    also can you post your viewObject source.

                    regards,
                    Rajan
                    ok this is my object source

                    public void changeDynamicVoNameTable(String Nomtable,String whereClause) { 
                    ViewObject dynamicVO = this.findViewObject("DynamicVO_view1");
                    dynamicVO.remove();
                    String sqlStatement=" select * from "+Nomtable+" where "+whereClause;
                    dynamicVO = this.createViewObjectFromQueryStmt("DynamicVO_view1", sqlStatement);
                    dynamicVO.executeQuery();
                    }

                    and then in backing bean i get the methode binding from my page jspx :

                    private String executeDynamiqueTable(String NomTable, String where) {
                    OperationBinding op = getOperationBinding("changeDynamicVoNameTable");
                    op.getParamsMap().put("Nomtable", NomTable);
                    op.getParamsMap().put("whereClause", where);
                    op.execute();
                    if (op.getErrors().size() != 0) {
                    return "Error";
                    } else {
                    return "Success";
                    }
                    }
                    then
                    executeDynamiqueTable("CTLPRH", "MOD_ID='" + currentRowPeriode.getModId() + "'");
                    ViewObject veiwCtlPrh = (ViewObject)findViewObject("AppModulePaieDataControl", "DynamicVO_view1");

                    while (veiwCtlPrh.hasNext()) {
                    if (i == 0)
                    row = veiwCtlPrh.first();
                    else
                    row = veiwCtlPrh.next();

                    String cphReqSql = (String)row.getAttribute("EmpMat");
                    • 7. Re: dynamic viewObject
                      Rajan M
                      OK...here DynamicVO_view1 is your ViewObject. You need to check the source for the ViewObject if that attribute exists.

                      regards,
                      Rajan
                      • 8. Re: dynamic viewObject
                        Manish
                        you can not get value of attribute using Attribute name on Dynamic vo

                        String cphReqSql = (String)row.getAttribute("EmpMat");

                        in place of this line

                        first attribute value-

                        String cphReqSql = (String)row.getAttribute(0);

                        second attribute value-

                        String cphReqSql1 = (String)row.getAttribute(1);
                        • 9. Re: dynamic viewObject
                          OraInfo
                          no the attribute does not exist in the view object ,it is a dynamic view ,i used it to execute many query sql in different table .

                          <?xml version="1.0" encoding="windows-1252" ?>
                          <!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
                          <!---->
                          <ViewObject
                          xmlns="http://xmlns.oracle.com/bc4j"
                          Name="DynamicVO_view"
                          Version="11.1.2.62.76"
                          BindingStyle="OracleName"
                          CustomQuery="true"
                          PageIterMode="Full"
                          UseGlueCode="false">
                          <DesignTime>
                          <Attr Name="_isExpertMode" Value="true"/>
                          </DesignTime>
                          <Properties>
                          <SchemaBasedProperties>
                          <LABEL
                          ResId="tn.simac.model.view.dynamiqueVO.DynamicVO_view_LABEL"/>
                          </SchemaBasedProperties>
                          </Properties>
                          <SQLQuery><![CDATA[select * from dual]]></SQLQuery>
                          <ViewAttribute
                          Name="Dummy"
                          IsUpdateable="false"
                          IsPersistent="false"
                          PrecisionRule="true"
                          Precision="255"
                          Type="java.lang.String"
                          ColumnType="VARCHAR2"
                          AliasName="DUMMY"
                          Expression="DUMMY"
                          SQLType="VARCHAR">
                          <DesignTime>
                          <Attr Name="_DisplaySize" Value="1"/>
                          </DesignTime>
                          </ViewAttribute>
                          <ResourceBundle>
                          <PropertiesBundle
                          PropertiesFile="tn.simac.model.ModelBundle"/>
                          </ResourceBundle>
                          </ViewObject>
                          • 10. Re: dynamic viewObject
                            Rajan M
                            In your ViewObject source, your required attribute EmpMat is not there. Hence the
                            row.getAttribute("EmpMat");
                            line is failing.
                            In your ViewObject, go to overview tab and add a new attribute (click on plus sign) in Attributes. Name it as 'EmpMat'
                            This adds the new attribute and automatically adds getter and setter method in your VORowImpl class (if required).

                            then you can call
                            row.getAttribute("EmpMat");
                            line.
                            This should work.

                            regards,
                            Rajan
                            • 11. Re: dynamic viewObject
                              OraInfo
                              yes i tried this but the same problem percist

                              while (veiwCtlPrh.hasNext()) {
                              if (i == 0)
                              row = veiwCtlPrh.first();
                              else
                              row = veiwCtlPrh.next();

                              String cphReqSql = (String)row.getAttribute(i);

                              i++
                              }

                              Edited by: OraInfo on 6 mai 2013 06:47
                              • 12. Re: dynamic viewObject
                                OraInfo
                                but i use this view for different sql query ,so it can take different attribute,for exemle i use it for the table emplye to get the emp value ,and others case i use it to get empDep fro table department.
                                • 13. Re: dynamic viewObject
                                  Manish
                                  don't use row index number

                                  give fixed value like 0,1,2

                                  because vo have many no of row like 100 but you have not 100 no of attribute.


                                  and can u post your log. and it is working on my case

                                  thanks
                                  • 14. Re: dynamic viewObject
                                    Manish
                                    code is following-
                                        public void getVal(ActionEvent actionEvent) {
                                            // Add event code here...
                                            BindingContext bindingctx=BindingContext.getCurrent();
                                            BindingContainer binding=bindingctx.getCurrentBindingsEntry();
                                            DCBindingContainer bindingsImpl = (DCBindingContainer) binding;
                                            DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("DynamicVo1Iterator");
                                            
                                            ViewObject vo=dciter.getViewObject();
                                          long cnt=  vo.getEstimatedRowCount();
                                          Row r;
                                          
                                          for(int i=0;i<cnt;i++) {
                                              
                                          if(i==0)
                                          {
                                     r= vo.first();
                                          }
                                              else
                                          {
                                              r=vo.next();
                                              }
                                         
                                           System.out.println(r.getAttribute(0)+"         "+r.getAttribute(1));
                                           
                                           
                                        
                                        }
                                          
                                        }
                                    1 2 Previous Next