Call a method before Next operation to set selected values

Use Case: I display a VO as a ADF Select Many Check Box. This VO is the detail of a master/detail. I managed to store the selection state in a managed bean on autoSubmit. Then the user navigate to the next master record, then goes back to the previous record. The Previous and Next buttons were created using the Operations in the data controls. I would like to put back the selection state when clicking on Previous or Next.
There is plenty of tutorial on how to get the selected values, but none on how to set the selected values. How would you do it?
JDev 11gR1

What I ended up doing:
1. Redefine action listener for the navigation buttons
    public void nextQuestion(ActionEvent event) {
        saveSelectedState();
        navigateQuestion("Next");
        restoreSelectedState();
    private void navigateQuestion(String operation) {
        OperationBinding operationBinding = ADFUtils.findOperation(operation);
        operationBinding.execute();
2. The save and restore selection state using bindings
     // Guava Multimap
    private ListMultimap<Number, Integer> selectedIndices;
    private void saveSelectedState() {
        // Get question id
        DCIteratorBinding questionBinding = ADFUtils.findIterator("QuestionsView1Iterator");
        Row question = questionBinding.getCurrentRow();
        Number questionId = (Number)question.getAttribute("Id");
        JUCtrlListBinding listBinding = (JUCtrlListBinding)ADFUtils.getBindingContainer().get("AnswersView2");
        int[] valueIndices = listBinding.getSelectedIndices();
        selectedIndices.putAll(questionId, Ints.asList(valueIndices));
    private void restoreSelectedState() {
        // Get question id
        DCIteratorBinding questionBinding = ADFUtils.findIterator("QuestionsView1Iterator");
        Row question = questionBinding.getCurrentRow();
        Number questionId = (Number)question.getAttribute("Id");
        int[] valueIndices = Ints.toArray(selectedIndices.get(questionId));
        JUCtrlListBinding listBinding = (JUCtrlListBinding)ADFUtils.getBindingContainer().get("AnswersView2");
        listBinding.setSelectedIndices(valueIndices);

Similar Messages

  • How to call AMImpl method before loading the page(task_flow_config.xml)

    Hi experts,
    I have requirement like,
    I need to call AmImpl method, before rendering the page.(I heard like we can do it in task_flow_config.xml by using method_Invoke operation,But I am not sure about How it is going to work, also i need to know the implementation part,,,help pls )
    (I need to do in Task_Flow.)
    Inside that method I have some logic, where I will setting the BindVariable of my one ViewObject and I need to run the ViewOblect,So that DataShuold be available while page loading.
    I have some different logic after that,,,,
    can anyone suggest me for this??
    thanks
    Santosh

    thanks to Timo n TK,
    I have use case like,
    In the search page I have 2 LOV dropdowns say LOV1 and LOV2. Both list of values are created based on the independent View Objects based on the Query.
    LOV2 VO query is having the Bind Variable, for that Bind variable will be getting the value from the one of the AM method based on the user logged in.
    Also I need to display LOV2 dropdown in the page when user selects LOV1 as a 'SCM', for others it should be in hidden state.
    As per requirement I have to display LOV2 only for LOV1 value as 'SCM'. So I dont want to use valueChangeListner() for this.
    Instead I want populate LOV2 value before page rendering(because in that time i will be having all the parameter to populate ) by executing LOV2 VO Query.
    Once in search page user selects LOV1 as 'SCM', I should display 'LOV2' values in the dropdown.
    If i execute LOV2 VO in the AMImpl method say A() before page rendering ,then if user select LOV1 as 'SCM', will same data available in the dropdown (LOV2 dropdown is based on the LOV2VO)??
    Can u pls suggest me how can i render ,LOV2 when LOV1 as 'SCM' by using 'rendered' property without having valueChangeListner??
    pls suggest me the right approach as per my use case..
    waiting for reply,,
    Thanks
    Santosh

  • Calling a method before entering a page

    Hi,
    What is the best way for calling a method before entering a page in ADF, when this page is the fist page that user in enter into it in Application, I mean there is not any other page before this page ( in this case I am able to call that method in task flow with method call).
    Also, I want this method calls only one time....
    Thanks.
    Edited by: Amir Khanof on Jun 29, 2010 5:19 AM

    Hi,
    one option would be to add a method for the afterPhase property of the f:view component on a JSPX page and listen for the after restore phase. Then check if the request (you get this from the FacesContext) is a GET request, which indicates that the page was requested from the browser and not in the process of navigating in the application. If the conditions are true, access the method and execute it
    Frank

  • Can we call a method before and after Export operations in ADF 11g

    Hi,
    My problem is I have to execute a method before and after the export operation.Is this posible in ADF 11g
    Regards,
    Felix

    Hi,
    in response to a similatr post of yours, I replied
    1. Drop af:exportCollectionActionListener on a command button
    2. set the command button to display = false
    3. In your Java code, call
    ActionEvent ae = new ActionEvent(button);
    ae.queue();
    Everything you put before
    ActionEvent ae = new ActionEvent(button);
    ae.queue();
    will fires as a pre-trigger, everything after as a post trigger
    Frank

  • How to call a method defined in AM when I select any value in LOV

    Lets say there is a LOV. The scenario is as soon as I select any value in LOV, a method needs to be called which I have written in the AM. And the output of the method is displayed in a output text box.
    I am not able to understand how to call a method when the user selects any value in LOV.
    This is wht I did. I had created the binding for the method. Changed the autosubmit property of the LOV to True, and in the properties of the output box, in the partial submit trigger property, passed the ID of the LOV. But I didnt get any place where I need to call the method. I am also not able to drop an action listener on the LOV

    Hi,
    +"its showing an error(underlined in orange)."+
    Any reason you don't share this error with us? Anyway, here is how it goes
    1. LOV, set autosubmit="true" and configure a value change listener
    2. Expose the AM method as a method binding in the PageDef file
    3. In the value change listener:
    BindingContext bctx = BindingContxt().getCurrent();
    BindingContainer bindings = bctx.getCurrentBindingsEntry();
    OperationBinding method = (OperationBinding) bindings.get("name of method binding in PageDef");
    method.getParamsMap().put("argument name1", value1);
    method.getParamsMap().put("argument name2", value2);
    Object retVal = method.execute();
    if(!method.getErrors().isEmpty()){
      //handle errors
    else{
      //write retVal to the managed bean variable that is referenced by the outputText value property
      //PPR output text component
      ADFFacesContext.getCurrentInstance().addPartialTarget(outputTextRef);
    }Note that you may have to set clientComponent = "true" on the output text component
    Frank

  • CF8 bound CFSelects setting selected value

    Hi,
    I have two CFSelects with one bound to the other. The first CFSelect is bound to a query and the second is bound to a cfc and references the first CFSelect.. From what I've been reading, in CF8 you can't set the selected value of a CFSelect bound to a CFC. This is problematic when I'm populating a form with data. I need to be able to set the selected value of the pulldown based on form data. Can anyone provide some insight as to how I might accomplish this.
    So when my form populates, the first CFSelect does set the selected value, but in doing so causes the second CFSelect to go and fetch data. I can't find a way to get the second CFSelect to set the selected value.

    Af course the Iterator is executed when the page loads since it is executable in PageDef. And it is setting the first value as a selected value. The unselectedLabel="empty" is adding new row in the drop down but that row (value) is not part of the iterator. The Iterator is not aware of that new value.
    Than why the framework let me add unselectedlabel (which) is new row in the list but I can not work with it (set it in the drop down programatically - initially)?
    What is more strange:
    public void customer_ValueChangeListener(ValueChangeEvent valueChangeEvent) {
    Object n = valueChangeEvent.getNewValue();
    value n in ValueChangeListener = null when "empty" value is selected (or the index of the selected row 0,1,2.. for any other selection)
    BUT the UI Binding value is not reset to null when "empty" value is selected:
    Object bind = facility_Binding.getValue();
    This bind value is holding the index of the selected row 0,1,2...(the same as above).
    But when the "empty" value is selected, this bind value is holding the old index. So they are out of sinc.
    <af:selectOneChoice value="#{bindings.AdFacilitiesLOV1.inputValue}" label="Facility:"
    shortDesc="#{bindings.AdFacilitiesLOV1.hints.tooltip}" id="soc1"
    unselectedLabel="empty" binding="#{pageFlowScope.GistExportBacking.facility_Binding}"
    autoSubmit="true"
    valueChangeListener="#{pageFlowScope.GistExportBacking.facility_ValueChangeListener}"
    partialTriggers="exp" disabled="#{bindings.FacilityFilter != 'Y'}">
    <f:selectItems value="#{bindings.AdFacilitiesLOV1.items}" id="si1"/>
    </af:selectOneChoice>
    Any solution of my problem?

  • Calling a method before page rendering begins

    I'm new to JSF. I'm looking for a way to get a method from my backing bean called AFTER page contents are initialized but BEFORE the page is rendered. I want to initialize some components dynamicaly and add them as children of an existing component, and then get everything rendered. How can it be done?

    What about binding a bean property to your component you wish to add to dynamically?
    Could you describe a little more of what you are trying to do? There may be a more elegant way of solving the problem.

  • Calling Controller method before page render

    Hi All,
    I have created menu in my web application using DHTML Tabber where each menu item is a link.
    I am using Facelets with JSF 1.2 .
    I want on click of each menu item a page should load in the body section of my template but before that I want a controllers method to be executed which would do some initializations. I cannot change the links in my menu to be <h:commandLink> since the menu is created using javascript (it cannot have <h:commandLink> in it) .
    How do I achieve this ?

    I think the issue here is generating the action on the server side when the link is selected.
    You might want to look into the solutions people have devised for so-called pretty URLs in JSF. Scales, a component library companion to Mojarra, the Sun RI, contains some support for these.
    Solutions that spring to mind off the top of my head are using a PhaseListener to detect the links and queue the event or using a placeholder component which processes the links in the decode (similar to how commandLink works).

  • ComboBox - Setting Selected Values from data

    I am running into a problem in Flex 3 that seems to be
    different from Flex 2. Maybe someone can help.
    I have a function for setting a combobox selected item for a
    location for a value when the titlewindow completes loading. The
    value is a prior value from a prior save. In other words to set the
    combobox a value from a prior session.
    The locations xml file is loaded from a remote object
    oncreationcomplete of the titlewindow. The setselectedvalue
    function worked perfectly in Flex 2 but now only works in Flex 2
    after the titlewindow is loaded. We tested this by running the
    setselectedvalue function from a button click after loading.
    The dataprovider length is showing 0 in our debugging. After
    titlewindow up on screen the length is showing correct ( 35 ) - in
    this case. Our viewxmlobject function is showing no xml. Shows xml
    correctly after up on screen.
    I have set the creationpolicy to "all". That did not help
    either.
    Any suggestions? Anyone. This is killing me. Spent two days
    now trying to get back to working state.
    private function SetSelectedValue_cbLocation(): void {
    var xLocID:String = eLocationID.text;
    //viewXmlObject( cbLocation.dataProvider )
    for (var i : int = 0; i < cbLocation.dataProvider.length
    ; i++) {
    //Alert.show( cbLocation.dataProvider
    .locid, 'Location DataProvider', Alert.OK);
    if ( xLocID == cbLocation.dataProvider.locid ){
    cbLocation.selectedIndex = i;
    break;
    The combobox has the dataprovider set at design time.
    <components:is2ComboBox id="cbLocation" x="585" y="4"
    width="196" dataProvider="{xmlLocations.Record}"
    labelField="locname" dataField="locid"
    change="changeLocation(event)" disabledColor="#004080" prompt="1.
    Please select location"></components:is2ComboBox>

    Hard to say without seeing the code. Is the application
    opening a pop-up window (the title window)? If so, where is the
    combo box located? In the main app or the titleWindow? What calls
    the SetSelectedValue_cbLocation() function?

  • How to set selected value in html:options that isusing HasMap Long,String

    So here is my problem
    I have a HashMap<Long,String> where key is the country id and value is the country name. So I am displaying it in the jsp using the below code
    <c-rt:set var="countriesMap" value="<%=countriesMap%>" target="java.util.HashMap<Long,String>"/>
    <html:select size="1" property="countryId" >
    <html:option value="" />
    <html:options collection="countriesMap" property="key" labelProperty="value" />
    </html:select>
    And my Action form has the property countryId.
    So it works fine , it displays all the countries and sets the country ID in the form's property that we set in the property attribute of <html:select>.The form's property is of type Long.
    But suppose if some error occurs in the validate method for some other property then when the page renders back it does not set the selected country in the list box.
    Can anyone please help me out of this.Thanks in advance.
    Edited by: AmitDsm on May 9, 2008 8:01 AM

    Hi,
    I had the same issue. Altho I am using Spring, the solution is the same.
    <select name="expMonth">
         <option value=""></option>
         <c:forEach items="${form.data.months}"
              var="month">
              <c:choose>
                   <c:when test="${form.data.pDet.expDate_month eq month}">
                        <option selected="selected"><c:out value="${month}"/></option>
                   </c:when>
                   <c:otherwise>
                        <option><c:out value="${month}"/></option>
                   </c:otherwise>
              </c:choose>
         </c:forEach>
    </select>Disclaimer: Not sure if this is the correct way to do it, but it works for me
    Edited by: Reegz on 2008/05/12 05:58

  • Not setting selected value in column of table control

    Hi,
    I have MATNR field in table control.
    In PAI code is as follow.
    PROCESS AFTER INPUT.
      MODULE CANCEL AT EXIT-COMMAND.
      MODULE VALIDATE.
      LOOP WITH CONTROL TC_FORMV.
      FIELD /SISLEMCU/CNVADTL-MATNR SELECT *
                          FROM  /SISLEMCU/CNVA01
                          WHERE WERKS = TXT_PLANT
                          AND CHARG =
                          /SISLEMCU/CNVADTL-CHARG.
                         INTO /SISLEMCU/CNVADTL.
      MODULE read_table_control.
      ENDLOOP.
    MODULE USER_COMMAND_0500.
    When i take the help in MATNR column the above query works fine but when i select the entry from help MATNR is not gets set in column in table control.
    Plz help me regarding this.
    Thankx in adv.
    Regards,
    Deepak.

    When you select a value, PBO as well as PAI gets triggered. When PAI gets triggered, your query gets executed which gives sy-subrc <> 0 and due to this it might not filling the data selected..

  • How to set Selected Value in InputSelect

    Hi,
    I have implemented InputSelect component from the BC4J, and the items(attributes) are retrieved and updated to the table correctly. However,there's an additional item, "None" appeared in the menu-list. I didn't insert any item of the value of "None". I referred back the sample of InputSelect in the Edit Record sample code, the list of items inside the menu are all from the table and there wasn't any item named "None". So, can anyone please tell me where did this "None" come from?
    Secondly, i would like to know how to make an item selected in a menu, so that it would be my initial value for the particular column?
    T.I.A,
    Sin Leng

    The 'none' option is automatically added when the database column accepts NULL as a value.

  • Any way (event) to call Java method after view created in JSF 2.0

    Hi,
    I am using JSF 2.0 Mojarra's implementation.
    I am interested to know if there is a way to call Java methods before and/or after view has been restored.
    I wanted to initialize data for my page in this Java method.
    I could see there is an event class PostRestoreStateEvent added in JSF 2.0. How to use it?
    I tired to use f:event element as below, but it does not work. Can anyone share anyother idea to achieve this behaviour?
    <f:metadata>
    <f:event type="postRestoreState" listener="#{employeeLoadBean.loadAfterRestoreView}"/>
    </f:metadata>
    Regards,
    Kishore K S

    Hi,
    The problem is solved as below.
    <f:metadata>
    <f:event type="javax.faces.event.PostRestoreStateEvent" listener="#{employeeViewEventListener.postRestoreState}"/>
    </f:metadata>
    The above calls the Java method #{employeeViewEventListener.postRestoreState} whenever View has been restored.
    It was not working when shortName of the event (ie., postRestoreState) is given and throwing ClassNotFound exception.
    Regards,
    Kishore K S

  • Contextual event - handler called before producer bean's setter

    I am trying a simple contextual events usecase:
    Page A.jsff has an input text field whose value is directly stored in a bean variable (bean is in pageFlowScope). Contextual event is defined on value change event for this input field. A.jsff has taskflow B_btf as an embedded region.This B_btf will simply display the value entered in the A.jsff. So, when contextual event is raised, the handler sets the value in a local variable of B_btf bean. The problem is that the handler method is getting called before the setter for the attribute of the bean of A.jsff. This is resulting in the B_btf displaying the last-but-one value entered in the input field of A.jsff instead of the current/latest value. Any tips?
    Thanks,
    Amitabh

    The issue was with the (lack of) understanding of the JSF lifecycle. The value change listener is called during the Process Validation phase, whereas the managed bean (Model) values will be set in the Update Model phase which lies next-in-line after Process Validation phase. Hence, if the value change listener is to be used, then the handler code should have used the default payload and not the custom payload. For a value change event the default payLoad will be a DCBindingContainerValueChangeEvent, and one can invoke getNewValue() to get the value entered in the text field (For details watch Frank Nimphius' video here: ADF Region Interaction - Contextual Events - YouTube). For my case, I added a command button to the page, and moved the contextual event to that button.

  • How to make set up with first call of method of a custom class?

    Hello
    I have build a custom class with a few custom methods.
    Method1 is called per every record of internal table. I need to set up certain parameters tha are the sme for all the calls  (populate the range , to fill the internal table , etc). This should be done only once.
    call method ZBW_CUSTOM_FUNCTIONS=>METHOD1
            exporting
              I = parameter1
            importing
              O = parameter2.
    Loop at ....
       <itab>-record1 = parameter2
    endloop.
    Methods2, 3 , 4 dont need any set up.
    Can somebody tell me how to do it within class?
    Thanks

    Instance methods (as opposed to static methods) are called on an object, which is an instance of a class. Broadly, think of the class as a template for the creation of objects. The objects created from the class take the same form as the class, but have their own state -- their own attribute values. In pseudo-ABAP (this won't even close to compile), let's say you have the following class:
    CLASS cl_class.
         STATICS static_attr TYPE string.
         DATA attr1 TYPE string.
         DATA attr2 TYPE i.
         CLASS-METHOD set_static_attr
              IMPORTING static_attr TYPE string.
              cl_class=>static_attr = static_attr.
         ENDMETHOD.
         METHOD constructor
              IMPORTING attr1 TYPE string
                                 attr2 TYPE i.
              me->attr1 = attr1.
              me->attr2 = attr2.
         ENDMETHOD.
         METHOD get_attr1
              RETURNING attr1 TYPE string.
              attr1 = me->attr1.
         ENDMETHOD.
    ENDCLASS.
    When you create an instance of the class (with CREATE OBJECT oref), the constructor is implicitly called. You can pass parameters to the constructor using: CREATE OBJECT oref EXPORTING attr1 = 'MyString' attr2 = 4.
    You then call methods on the instance you have created. So, oref-&gt;get_attr1( ) would return 'MyString'.
    The constructor is called when the object is created (so, when you call CREATE OBJECT). At this time, the setup is done, and any subsequent methods you call on the object will be able to use the attributes you set up in the constructor. Every object has its own state. If you had another object, oref2, changing its instance attribute values would not affect the values of oref.
    Static methods and attributes are different. A static attribute exists only once for all instances of the class -- they share a single value (within an internal session, I think. I'm not sure of the scope off-hand.) You also call static methods on the class itself, not on instances of it, using a different selector (=&gt; instead of -&gt;). So, if you called cl_class=&gt;set_static_attr( static_attr = 'Static string' ), 'Static string' would be the value of static_attr, which belongs to the class cl_class, and not instances of it. (You can also set up a class constructor, which is called when the class is loaded, but that's another subject.)
    To answer your question more succinctly: no, the constructor is not called before each method. It is only called when you create the object. Any subsequent methods called on the object can then access its attributes.
    Please have a look at [http://help.sap.com/saphelp_nw70ehp2/helpdata/en/48/ad3779b33a11d194f00000e8353423/frameset.htm] for a more thorough treatment of basic object concepts. (The rest of that documentation is very thin, but it'll get you started. Also, it doesn't appear to deal with statics. You'll have to look elsewhere for that.)

Maybe you are looking for

  • Scenarios Upgrade from PI 7.0 to PI 7.1

    Hi All, I have my Design Objects (like Message Interfaces, Graphical Mapping, BPM , WebServices as External Definations, Proxies etc. ) and Configuration Objects (like Adapters etc. ) developed in PI 7.0. I want to migrate all my scenarios from PI 7.

  • Sapscript:To place text elements according to x-y coordinates

    Hi All, I have a requirement in which I have to print texts through sap script very accurately .Their x-y coordinate  position is given. I know to use this for boxes but can some one guide me to use these for the texts Regards, Vivek

  • Sql injection avoiding

    If someone enters sql commands into a text element for address or name, how does cfqueryparam help protect against sql injection ? Would a regular expression or something checking for dangerous key words help at least as much ?

  • Error chrome://tavgp/content/libs/include.js:595

    When opening Firefox 4.0 Beta 12 the script chrome://tavgp/content/libs/include.js:595 stop then I have to stop the script to get the navigator open. An other message on the navigator says: Firefox is not able to show the Toolbar. Please re-install t

  • Switched from CS to just Muse

    I subscribed to Creative Cloud CS for a year. During that year I created a website with Muse. Now I cancelled my subscription to CS and sunscribed to just Muse. The reason was for email purposes.  My question is two fold. First do I need to switch so