This discussion is archived
1 2 Previous Next 22 Replies Latest reply: Apr 18, 2013 2:42 AM by 1002630 RSS

Refresh SelectOneChoice

1002630 Newbie
Currently Being Moderated
Hi there!

I'm using JDeveloper 11g Release 2 (11.1.2.3.0). I have a SelectOneChoice in my application wich display a LOV coming from another VO. When I add a new value programmatically, how can I refresh this SelectOneChoice to show the new value added?

Thanks in advance!
  • 1. Re: Refresh SelectOneChoice
    prateekazam Journeyer
    Currently Being Moderated
    Hi ,

    Binding with backing bean and try to programmatically refresh it.
    AdfFacesContext.getCurrentInstance().addParticalTraget(passyourbindingvariable);
    Thanks
    Prateek
  • 2. Re: Refresh SelectOneChoice
    1002630 Newbie
    Currently Being Moderated
    Hi Prateek!

    I'm new in ADF and I don't have so many experience...

    Where I put this sentence? In the ApplicationModuleImpl? in the VOImpl? I tried in both, and I received a message like "type or variable AdfFacesContext not found"...

    Thanks
  • 3. Re: Refresh SelectOneChoice
    Puthanampatti Guru
    Currently Being Moderated
    in your managed bean..

    add binding like binding="#{pageFlowScope.YourBean.soc}"

    AdfFacesContext.getCurrentInstance().addParticalTraget(soc);
  • 4. Re: Refresh SelectOneChoice
    1002630 Newbie
    Currently Being Moderated
    ok, I tried it and I'm not be able that this works...

    I explain the problem again:

    I have a SelectOneChoice populated with a LOV. This SelectOneChoice it's inside a form to create new employees (from EmployeesVO), and the user select a employeeDepartmentId. In my page, I have a button that show a pop up to create new Departments (DepartmentVO). When I add a new department in that pop up (I do it programmatically from DepartmentVOImpl), I want to refresh the SelectOneChoice to show the new Department added.

    Thanks for your help!
  • 5. Re: Refresh SelectOneChoice
    Puthanampatti Guru
    Currently Being Moderated
    try setting the popup save button's id as partialTriggers for SOC.
  • 6. Re: Refresh SelectOneChoice
    1002630 Newbie
    Currently Being Moderated
    Don't work :(
    Another idea?
  • 7. Re: Refresh SelectOneChoice
    prateekazam Journeyer
    Currently Being Moderated
    Hi ,

    I have created locally your use case and it is working without putting any extra code(Partial Target).
    Therefore might be you are doing some things wrong.Since both department iterator has pointed same iterator.

    Zip and share your application and give your link here.


    Thanks
    Prateek
  • 8. Re: Refresh SelectOneChoice
    Rafat Newbie
    Currently Being Moderated
    Hi,

    It seems that Data comes in your LOV from department Vo.so After adding new department re-execute(deparmentvo.executeQuery) your department VO.

    Rafat
  • 9. Re: Refresh SelectOneChoice
    1002630 Newbie
    Currently Being Moderated
    It don't work :(

    I put some code, probably you'll be able to find the problem...

    The pop up in the jsf file:
    <af:popup childCreation="deferred" autoCancel="disabled" id="p2">
                        <af:panelWindow id="pw1">
                            <af:inputText label="Nuevo Modelo" id="it7" value="#{nuevoModelo.modeloNombre}"/>
                            <af:commandButton actionListener="#{bindings.addNuevoModelo.execute}" text="Guardar"
                                              disabled="#{!bindings.addNuevoModelo.enabled}" id="cb7"
                                              inlineStyle="margin-top:10px; margin-left: 80px;"/>
                        </af:panelWindow>
                    </af:popup>
    The form with the selectOneChoice on first position:
    <af:panelFormLayout partialTriggers="md1" id="pfl1"
                                                                    inlineStyle="margin-top:8px; margin-left:150px; width: 400px; float:left;">
                                                <af:commandButton text="Nuevo..." id="cb6"
                                                                  inlineStyle="position: absolute; left: 330px;">
                                                    <af:showPopupBehavior popupId="::p2" triggerType="action"/>
                                                </af:commandButton>
                                                <af:selectOneChoice value="#{bindings.CocModId1.inputValue}"
                                                                    label="Modelo"
                                                                    required="#{bindings.CocModId1.hints.mandatory}"
                                                                    shortDesc="#{bindings.CocModId1.hints.tooltip}"
                                                                    id="soc1" partialTriggers="::cb7">
                                                    <f:selectItems value="#{bindings.CocModId1.items}" id="si1"/>
                                                </af:selectOneChoice>
                                                <af:inputText value="#{bindings.CocColor.inputValue}"
                                                              label="Color"
                                                              required="#{bindings.CocColor.hints.mandatory}"
                                                              columns="#{bindings.CocColor.hints.displayWidth}"
                                                              maximumLength="#{bindings.CocColor.hints.precision}"
                                                              shortDesc="#{bindings.CocColor.hints.tooltip}" id="it1">
                                                    <f:validator binding="#{bindings.CocColor.validator}"/>
                                                </af:inputText>
                                                <af:toolbar id="t1">
                                                    <af:commandButton actionListener="#{bindings.crearNuevoCocheYStock.execute}"
                                                                      text="Nuevo Coche"
                                                                      disabled="#{!bindings.crearNuevoCocheYStock.enabled}"
                                                                      id="cb3"/>
                                                    <af:commandButton actionListener="#{bindings.Commit.execute}"
                                                                      text="Guardar"
                                                                      id="cb5"/>
                                                </af:toolbar>
                                            </af:panelFormLayout> 
    The method in ModeloVOImpl:
    public void addNuevoModelo(String modeloNombre){
            
            RowSet rs = this.getRowSet();
            NameValuePairs atributes = new NameValuePairs();
            ModeloVORowImpl newRow = (ModeloVORowImpl)rs.createAndInitRow(atributes);
            
            DBSequence seq = new DBSequence(getDBSequenceValue("SEQ_MODELO"));
            newRow.setModId(new Long(seq.getSequenceNumber().longValue()));
            newRow.setModNombre(modeloNombre);
            newRow.setModMarId(getBindMarcaId());
            
            this.setCurrentRow(newRow);
            
            this.getApplicationModule().getTransaction().commit();
    
            ItaAppModule am = (ItaAppModule)getApplicationModule();
            am.refreshModeloVO();
    
        }
        
        public Number getDBSequenceValue(String sequenceName){
            SequenceImpl dS;
            Number seqNumber = null;
            try {
            dS = new SequenceImpl(sequenceName, getDBTransaction());
            seqNumber=dS.getSequenceNumber();
            } catch (Exception ex) { 
            }
            return seqNumber;
        }
    And finally, the method in the AM that refresh it:
    public void refreshModeloVO(){
            ModeloVOImpl modeloVO = getModeloVO();
            modeloVO.executeQuery();
        }
    Thanks!!!
  • 10. Re: Refresh SelectOneChoice
    Timo Hahn Oracle ACE
    Currently Being Moderated
    You have to refresh the binding layer (the iterator your selectOneChoice is based on). You are just refreshing the model layer without the binding layer noticing it.
    After you add the new element ot the VO you need to get the iterator (CocModId1) and execute the it again.

    Timo
  • 11. Re: Refresh SelectOneChoice
    1002630 Newbie
    Currently Being Moderated
    Hi Timo!

    Thank you for your answers, you're help me so much!

    Here is my managed bean with the method that you told me:

    public class NuevoModelo {
        
        private String modeloNombre;
    
        public void setModeloNombre(String modeloNombre) {
            this.modeloNombre = modeloNombre;
        }
    
        public String getModeloNombre() {
            return modeloNombre;
        } 
        
        public void refreshData(){
            DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
            DCIteratorBinding iter = bindings.findIteratorBinding("CocModId1");
            iter.executeQuery();    
        }
    }
    Where and how I can call this method to refresh the iter?
  • 12. Re: Refresh SelectOneChoice
    Timo Hahn Oracle ACE
    Currently Being Moderated
    I would put this code to the method you use to add the element to the LOV.
    As you have to call two methods if the user clicks 'Guardar' button you should bind the actionListener to a bean and call both methods from the bean.

    Timo
  • 13. Re: Refresh SelectOneChoice
    Rafat Newbie
    Currently Being Moderated
    Hi,
    can u a post your
    <af:commandButton actionListener="#{bindings.addNuevoModelo.execute}"
    execute mehod code.

    (You can call your refreshData() method inside execute method)

    RAFAT
  • 14. Re: Refresh SelectOneChoice
    1002630 Newbie
    Currently Being Moderated
    Finally I change the method in ModeloVOImpl like:
    public void addNuevoModelo(String modeloNombre){
            
            RowSet rs = this.getRowSet();
            NameValuePairs atributes = new NameValuePairs();
            ModeloVORowImpl newRow = (ModeloVORowImpl)rs.createAndInitRow(atributes);
            
            DBSequence seq = new DBSequence(getDBSequenceValue("SEQ_MODELO"));
            newRow.setModId(new Long(seq.getSequenceNumber().longValue()));
            newRow.setModNombre(modeloNombre);
            newRow.setModMarId(getBindMarcaId());
            
            this.setCurrentRow(newRow);
            
            this.getApplicationModule().getTransaction().commit();
            
            refreshData();
        }
        
        public void refreshData(){
            DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
            DCIteratorBinding iter = bindings.findIteratorBinding("CocModId1");
            iter.executeQuery();    
        }
    But when I click in "Guardar" button, I get a Null Pointer Exception in line:
    iter.executeQuery(); 
    :(
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points