Discussions
Categories
- 196.9K All Categories
- 2.2K Data
- 239 Big Data Appliance
- 1.9K Data Science
- 450.4K Databases
- 221.7K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 550 MySQL Community Space
- 478 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 546 SQLcl
- 4K SQL Developer Data Modeler
- 187.1K SQL & PL/SQL
- 21.3K SQL Developer
- 295.9K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.6K Development Tools
- 107 DevOps
- 3.1K QA/Testing
- 646K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 155 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 18 Java Essentials
- 160 Java 8 Questions
- 86K Java Programming
- 80 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 204 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 443 LiveLabs
- 38 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 171 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 232 Portuguese
ADF Faces - How to create an editable rich table at runtime

809994
Member Posts: 4
Hi,
JDeveloper version - 11.1.1.4.0
I have been trying to create an editable table (wherein the user can enter text into the input text boxes contained in the columns added at runtime). The values thus entered are to be captured in the backing bean for further processing.
Below are my attempts to achieve this in various ways but without success.
Attempt 1 : Created a Read-Only Dynamic table by dropping the view object instance from the Data Control. Here, the default being output text components, I used input text components and programatically make it updatable in the backing bean, which however, shows as an output text component.
1) UI - .jspx file
1) UI - .jspx file
Below code however, creates a new instance of RichTable. Also, if an overloaded method is invoked on an ActionEvent, the columns added are not displayed.
Thanks for your time.
Dinu
JDeveloper version - 11.1.1.4.0
I have been trying to create an editable table (wherein the user can enter text into the input text boxes contained in the columns added at runtime). The values thus entered are to be captured in the backing bean for further processing.
Below are my attempts to achieve this in various ways but without success.
Attempt 1 : Created a Read-Only Dynamic table by dropping the view object instance from the Data Control. Here, the default being output text components, I used input text components and programatically make it updatable in the backing bean, which however, shows as an output text component.
1) UI - .jspx file
<af:table rows="#{bindings.TestViewObject1.rangeSize}" fetchSize="#{bindings.TestViewObject1.rangeSize}" emptyText="#{bindings.TestViewObject1.viewable ? 'No data to display.' : 'Access Denied.'}" var="row" rowBandingInterval="0" value="#{bindings.TestViewObject1.collectionModel}" selectedRowKeys="#{bindings.TestViewObject1.collectionModel.selectedRow}" selectionListener="#{bindings.TestViewObject1.collectionModel.makeCurrent}" rowSelection="single" id="t1" partialTriggers="::cb1 ::cb2" binding="#{TestDynamicTable.t1}"> <af:forEach items="#{TestDynamicTable.attributeDefns}" var="def"> <af:column headerText="#{def.name}" sortable="true" sortProperty="#{def.name}" id="c1"> <af:inputText value="#{row[def.name]}" id="it1" label="Label 1" autoSubmit="true" /> </af:column> </af:forEach> </af:table>2) Backing bean -
public void listenMeForAction(ActionEvent ae) { //adding attribute dynamically ViewAttributeDefImpl def = (ViewAttributeDefImpl)vo.addDynamicAttribute("testDynamicAttr"+columnCount); def.setUpdateableFlag(def.UPDATEABLE); byte b = def.UPDATEABLE; def.setEditable(true); //def.setProperty(def.ATTRIBUTE_CTL_TYPE,); //def.getUIHelper().HINT_NAME_UPDATEABLE def.setProperty(def.ATTRIBUTE_DISPLAY_HINT_DISPLAY, def.HINT_NAME_UPDATEABLE); columnCount ++ ; AdfFacesContext.getCurrentInstance().addPartialTarget(this.t1); }Attempt 2 : Created a ADF table by dropping the view object instance from the Data Control. Here, the columns and its cells are added programatically in the backing bean. However
1) UI - .jspx file
<af:table value="#{bindings.Test5ViewObj1.collectionModel}" var="row" rows="#{bindings.Test5ViewObj1.rangeSize}" emptyText="#{bindings.Test5ViewObj1.viewable ? 'No data to display.' : 'Access Denied.'}" fetchSize="#{bindings.Test5ViewObj1.rangeSize}" rowBandingInterval="0" id="richDynamicTable" binding="#{TestDynamicTable.richDynamicTable}"> </af:table>2) Backing bean - When the buildRichTable method is invoked from the constructor, the table shows the input text boxes as required, but the entered values is not getting retrieved (). Tried adding a valuchangelistener to the added cell, but this does not fire as well.
Below code however, creates a new instance of RichTable. Also, if an overloaded method is invoked on an ActionEvent, the columns added are not displayed.
//called from costructor public void buildRichTable() { dynamicVO.clearCache(); //create this table richDynamicTable = new RichTable(); int noOfCols = 2; for(int i=0; i<noOfCols; i++) { //create new column for the table richDynamicCol = new RichColumn(); richDynamicCol.setHeaderText("ColTest"+i); // richDynamicCol.isVisible() // richDynamicCol.setVisible(arg0); richDynamicCol.setParent(richDynamicTable); richDynamicTable.getChildren().add(richDynamicCol); richDynamicTable.getChildCount(); richDynamicTable.getRowCount(); richDynamicCell = new RichInputText(); richDynamicCell.setLabel("aCell"+i); // richDynamicCell.isVisible() MethodExpression methodExpression = FacesContext.getCurrentInstance().getApplication(). getExpressionFactory().createMethodExpression( FacesContext.getCurrentInstance().getELContext(), "#{TestDynamicTable.inputBoxValueChangeListener}", null, new Class[] {ValueChangeEvent.class}); //this does not work too - on adding some text and tabbing out richDynamicCell.addValueChangeListener(new MethodExpressionValueChangeListener(methodExpression)); richDynamicCell.setParent(richDynamicCol); richDynamicCell.setValue("#{row.ColTest"+i+"}"); richDynamicCol.getChildCount(); richDynamicCol.getChildren().add(richDynamicCell); dynamicVO.addDynamicAttribute("ColTest"+i); } //dynamicVO.insertRow(dynamicVO.createRow()); dynamicVO.getRowCount(); AdfFacesContext.getCurrentInstance().addPartialTarget(this.getRichDynamicTable()); AdfFacesContext.getCurrentInstance().addPartialTarget(this.getRichDynamicCol()); AdfFacesContext.getCurrentInstance().addPartialTarget(this.getRichDynamicCell()); buildTable = false; this.setDynamicVO(dynamicVO); }
//captures the input data public void captureRichTableData(ActionEvent ae) { //gives null below this.getDynamicVO().getCurrentRow().getAttribute("ColTest0"); this.getDynamicVO().getCurrentRow().getAttribute("ColTest1"); //again null List<UIComponent> listCols = richDynamicTable.getChildren(); for(UIComponent aColComp : listCols) { RichColumn aCol = (RichColumn)aColComp; List<UIComponent> listCells = aCol.getChildren(); for(UIComponent aCellComp : listCells) { RichInputText anInputText = (RichInputText)aCellComp; anInputText.getValue(); } } }Not sure what I must be missing. May be I need to add bindings to the text boxes added but cant figure how to go about it. I found some posts on dynamically adding columns pointing to displaying contained data. Any help would be highly appreciated.
Thanks for your time.
Dinu
Answers
-
Hi,
Not too sure if I am heading the right way, but tried adding the bindings and value expression at runtime for the added columns. The values added at the screen is again found null at the VO and RichInputText child / cell. The updated method is as below -buildRichTable() { ... ... //adding binding for the added cell DCBindingContainer bc = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry(); if(bc.findCtrlBinding("ColTest"+i) == null) { bc.addControlBinding("ColTest"+i, new JUCtrlAttrsBinding(null, bc.findIteratorBinding("Test5ViewObj1Iterator"), new String[]{"ColTest"+i})); } //the expression to be set in value attribute for richInputText component String theExpression = "#{row.bindings."+"ColTest"+i+".inputValue}"; //setting the expression richDynamicCell.setValueExpression("ColTest"+i, getValueExpression(theExpression)); richDynamicCell.setAutoSubmit(true); richDynamicCol.getChildCount(); richDynamicCol.getChildren().add(richDynamicCell); dynamicVO.addDynamicAttribute("ColTest"+i); } dynamicVO.insertRow(dynamicVO.createRow()); dynamicVO.getRowCount(); AdfFacesContext.getCurrentInstance().addPartialTarget(this.getRichDynamicTable()); AdfFacesContext.getCurrentInstance().addPartialTarget(this.getRichDynamicCol()); AdfFacesContext.getCurrentInstance().addPartialTarget(this.getRichDynamicCell()); buildTable = false; this.setDynamicVO(dynamicVO); } private ValueExpression getValueExpression(String theExpression) { FacesContext fc = FacesContext.getCurrentInstance(); Application app = fc.getApplication(); ExpressionFactory elFactory = app.getExpressionFactory(); ELContext elContext = fc.getELContext(); return elFactory.createValueExpression(elContext, theExpression, Object.class); }
It would be great help to have any leads.
Thanks,
Dinu -
hi,
did u fix this issue?
if u fix it, can u reply with code?
thanks
This discussion has been closed.