Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Multiple Multishuffles

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Multiple Multishuffles

    Hello everyone I use Jdeveloper 11g R2 and have 3 multishuttles on my jsp that are all supposed to refresh when navigation buttons are pressed.

    This means all the multishuttle code should be in a single backing bean, so the navigation button could call the refresh method from that bean, which would refresh all three.

    This is the code I have

    package view.backingbeans;
     
     
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    import view.objekti.utils.JSFUtils;
    import javax.faces.application.FacesMessage;
    import javax.faces.context.FacesContext;
    import javax.faces.event.ActionEvent;
    import javax.faces.event.ValueChangeEvent;
    import javax.faces.model.SelectItem;
     
    import oracle.adf.model.BindingContext;
    import oracle.adf.model.binding.DCBindingContainer;
    import oracle.adf.model.binding.DCIteratorBinding;
     
    import oracle.adf.view.rich.component.rich.nav.RichCommandToolbarButton;
     
    import oracle.binding.AttributeBinding;
     
    import oracle.binding.BindingContainer;
    import oracle.binding.OperationBinding;
     
    import oracle.jbo.Row;
    import oracle.jbo.domain.Number;
     
     
    public class FormShuttle {
     
      private RichCommandToolbarButton Next1;
     
        public FormShuttle() {
            super();
        }
        List selectedFruits;
        List allFruits;
        List selectedTerminali;
        List allTerminali;
        Boolean refreshSelectedList = false;
     
     
        public void setSelectedFruits(List selectedItems) {
            this.selectedFruits = selectedItems;
        }
     
        public List getSelectedFruits() {
            if (selectedFruits == null || refreshSelectedList) {
                selectedFruits =
                        attributeListForIterator("KonekcijeView1Iterator",
                                                 "AdslId");
                    //    attributeListForIterator("TerminaliUObjektuView1Iterator", "TipTerminalaId");
            }
            return selectedFruits;
        }
     
        public void setAllFruits(List allItems) {
            this.allFruits = allItems;
        }
     
     
        public static List attributeListForIterator(String iteratorName,
                                                    String valueAttrName) {
            BindingContext bc = BindingContext.getCurrent();
            DCBindingContainer binding =
                (DCBindingContainer)bc.getCurrentBindingsEntry();
            DCIteratorBinding iter = binding.findIteratorBinding(iteratorName);
            List attributeList = new ArrayList();
            for (Row r : iter.getAllRowsInRange()) {
                attributeList.add(r.getAttribute(valueAttrName));
            }
            return attributeList;
        }
     
        public List getAllFruits() {
            if (allFruits == null) {
                allFruits =
                        selectItemsForIterator("AdslView1Iterator", "AdslId", "TipKonekcije");
            }
            return allFruits;
        }
     
        public static List<SelectItem> selectItemsForIterator(String iteratorName,
                                                              String valueAttrName,
                                                              String displayAttrName) {
            BindingContext bc = BindingContext.getCurrent();
            DCBindingContainer binding =
                (DCBindingContainer)bc.getCurrentBindingsEntry();
            DCIteratorBinding iter = binding.findIteratorBinding(iteratorName);
            List<SelectItem> selectItems = new ArrayList<SelectItem>();
            for (Row r : iter.getAllRowsInRange()) {
                selectItems.add(new SelectItem(r.getAttribute(valueAttrName),
                                               (String)r.getAttribute(displayAttrName)));
            }
            return selectItems;
        }
     
        public void refreshSelectedList() {
            refreshSelectedList = true;
        }
     
        public Number getCurrentPersonId() {
            BindingContext bctx = BindingContext.getCurrent();
            DCBindingContainer bindings =
                (DCBindingContainer)bctx.getCurrentBindingsEntry();
            AttributeBinding attr = (AttributeBinding)bindings.get("ObjekatId2");
            Number personId = (Number)attr.getInputValue();
            return personId;
        }
     
     
        public String processShuttle() {
            BindingContext bctx = BindingContext.getCurrent();
            DCBindingContainer binding =
                (DCBindingContainer)bctx.getCurrentBindingsEntry();
            DCIteratorBinding iter =
                (DCIteratorBinding)binding.get("KonekcijeView1Iterator");
     
            //Removing all rows
            for (Row r : iter.getAllRowsInRange()) {
                r.remove();
            }
     
            if (this.getSelectedFruits().size() > 0) {
                for (int i = 0; i < selectedFruits.size(); i++) {
     
                    Row row = iter.getRowSetIterator().createRow();
     
                    row.setNewRowState(Row.STATUS_INITIALIZED);
                    row.setAttribute("ObjekatId", getCurrentPersonId());
                    row.setAttribute("AdslId", getSelectedFruits().get(i));
     
                    iter.getRowSetIterator().insertRow(row);
                    iter.setCurrentRowWithKey(row.getKey().toStringFormat(true));
                    System.out.println("inside ");
                }
            }
            String ok = doCommit();
            System.out.println("Commit value" + ok);
            return null;
        }
     
      public String doCommit() {
          BindingContainer bindings = getBindings();
          OperationBinding operationBinding =
              bindings.getOperationBinding("Commit");
          Object result = operationBinding.execute();
          if (operationBinding.getErrors().isEmpty()) {
             /*  List errors = operationBinding.getErrors();
              Iterator<oracle.jbo.JboException> iterator = errors.iterator();
              while (iterator.hasNext()) {
                  FacesMessage fm =
                      new FacesMessage(FacesMessage.SEVERITY_ERROR, iterator.next().getMessage(),
                                       null);
                  FacesContext fctx = FacesContext.getCurrentInstance();
                  fctx.addMessage(null, fm);
              } */
     
              return "problem";
          }
          return "ok ki flight";
      }
     
     
     
      public void setSelectedTerminali(List selectedItems) {
          this.selectedTerminali = selectedItems;
      }
     
      public List getSelectedTerminali() {
          if (selectedTerminali == null || refreshSelectedList) {
              selectedTerminali =
                      attributeListForIterator2("TerminaliUObjektuView1Iterator",
                                               "TipTerminalaId");
          }
          return selectedTerminali;
      }
     
      public void setAllTerminali(List allItems) {
          this.allTerminali = allItems;
      }
     
     
      public static List attributeListForIterator2(String iteratorName,
                                                  String valueAttrName) {
          BindingContext bc = BindingContext.getCurrent();
          DCBindingContainer binding =
              (DCBindingContainer)bc.getCurrentBindingsEntry();
          DCIteratorBinding iter = binding.findIteratorBinding(iteratorName);
          List attributeList = new ArrayList();
          for (Row r : iter.getAllRowsInRange()) {
              attributeList.add(r.getAttribute(valueAttrName));
          }
          return attributeList;
      }
     
      public List getAllTerminali() {
          if (allTerminali == null) {
              allTerminali =
                      selectItemsForIterator2("TipTerminalaView1Iterator", "TipTerminalaId", "Naziv");
          }
          return allTerminali;
      }
     
      public static List<SelectItem> selectItemsForIterator2(String iteratorName,
                                                            String valueAttrName,
                                                            String displayAttrName) {
          BindingContext bc = BindingContext.getCurrent();
          DCBindingContainer binding =
              (DCBindingContainer)bc.getCurrentBindingsEntry();
          DCIteratorBinding iter = binding.findIteratorBinding(iteratorName);
          List<SelectItem> selectItems = new ArrayList<SelectItem>();
          for (Row r : iter.getAllRowsInRange()) {
              selectItems.add(new SelectItem(r.getAttribute(valueAttrName),
                                             (String)r.getAttribute(displayAttrName)));
          }
          return selectItems;
      }
     
     {
          refreshSelectedList = true;
      }
     
      public Number getCurrentObjekatId() {
          BindingContext bctx = BindingContext.getCurrent();
          DCBindingContainer bindings =
              (DCBindingContainer)bctx.getCurrentBindingsEntry();
          AttributeBinding attr = (AttributeBinding)bindings.get("ObjekatId2");
          Number objekatId = (Number)attr.getInputValue();
          return objekatId;
      }
     
     
      public String processShuttle2() {
          BindingContext bctx = BindingContext.getCurrent();
          DCBindingContainer binding =
              (DCBindingContainer)bctx.getCurrentBindingsEntry();
          DCIteratorBinding iter =
              (DCIteratorBinding)binding.get("TerminaliUObjektuView1Iterator");
     
          //Removing all rows
          for (Row r : iter.getAllRowsInRange()) {
              r.remove();
          }
     
          if (this.getSelectedTerminali().size() > 0) {
              for (int i = 0; i < selectedTerminali.size(); i++) {
     
                  Row row = iter.getRowSetIterator().createRow();
     
                  row.setNewRowState(Row.STATUS_INITIALIZED);
                  row.setAttribute("ObjekatId", getCurrentObjekatId());
                  row.setAttribute("TipTerminalaId", getSelectedTerminali().get(i));
     
                  iter.getRowSetIterator().insertRow(row);
                  iter.setCurrentRowWithKey(row.getKey().toStringFormat(true));
                  System.out.println("inside ");
              }
          }
          String ok = doCommit();
          System.out.println("Commit value" + ok);
          return null;
      }
     
     
      public BindingContainer getBindings() {
          return BindingContext.getCurrent().getCurrentBindingsEntry();
      }
     
     
        public String previous_action() {
            BindingContainer bindings = getBindings();
            OperationBinding operationBinding = bindings.getOperationBinding("Previous");
            Object result = operationBinding.execute();
            if (!operationBinding.getErrors().isEmpty()) {
                return null;
            }
            refreshSelectedList();
            return null;
        }
     
     
     
     
      public String adslSljedeciButton_action() {
          if(((Boolean)JSFUtils.getManagedBeanValue("bindings.Commit.enabled")) == false) {
              BindingContainer bindings = getBindings();
              OperationBinding operationBinding = bindings.getOperationBinding("Next1");
              Object result = operationBinding.execute();
              if (!operationBinding.getErrors().isEmpty()) {
                  return null;
              }
          } else {
              FacesContext context = FacesContext.getCurrentInstance();
              context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Napravili ste neke izmjene morate ih prvo pohraniti ili povratiti" +
                  " prije nego mozete nastaviti!", null));
          }
     
        refreshSelectedList();
        return null;
     
      }
      public void setNext1(RichCommandToolbarButton Next1) {
          this.Next1 = Next1;
      }
     
      public RichCommandToolbarButton getNext1() {
          return Next1;
      }
    }

    Unfortunately this comes with problems when commiting the values (the refresh works), as the values are not stored in the database, and I get a commit value problem output message. If I put them in separate java classes it works, and will commit for all three, but the refresh button only works for one multishuttle (the one that has the method it uses for action).

    I am a beginner in Java so really any help would be greatly appreciated.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

  3. #3
    Junior Member
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Multiple Multishuffles

    Can anyone help me?

  4. #4
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: Multiple Multishuffles

    One more: This thread has been cross posted here:

    http://www.java-forums.org/new-java/34502-multiple-multishuffles.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting

    db


Similar Threads

  1. working with multiple threads
    By retsameht in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 9th, 2010, 01:36 PM
  2. multiple tcp connection?
    By nasser in forum Java Networking
    Replies: 4
    Last Post: July 31st, 2010, 07:35 AM
  3. Multiple JFrames
    By Scottj996 in forum AWT / Java Swing
    Replies: 1
    Last Post: April 15th, 2010, 05:24 AM
  4. Multiple Queues
    By fh84 in forum Threads
    Replies: 1
    Last Post: December 3rd, 2009, 02:28 PM
  5. Which interface gives more control on serialization of an object?
    By abhishekraok2003 in forum Java Theory & Questions
    Replies: 1
    Last Post: May 16th, 2009, 10:17 AM