4 Replies Latest reply on May 26, 2009 5:51 AM by Ruben Jorge

    Accessing param values using Drag n Drop

    Ruben Jorge Newbie

      Hello everyone,

      I'm using drag and drop support and I want to pass an additional parameter so that I can access it's value when processing the dragged/dropped object.

      My JSP has:

      <rich:dragSupport dragIndicator=":indicator" dragType="measure" dragValue="#{measure}">
       <a4j:actionparam name="operator" value="#{aggOp}" assignTo="#{SessionBean.tempAggOp}"/>
       <rich:dndParam name="label" value="#{measure.name} (#{aggOp})"/>
      </rich:dragSupport>
      <h:outputText value="#{aggOp}" style="font:11px arial;"/>
      


      On my backing bean method that processes the event, I can access the object's properties fine, but the param has a strange behaviour:

      The first time I drag an object, the param value is null on the bean. The second time, it has the value it should have for the first dragged object, and so on.

      Apparently the param value is being updated *after* the drop event method is called. Any ideas on how to change this please?

      Thanks in advance,
      ~Ruben

        • 1. Re: Accessing param values using Drag n Drop
          Nick Belaevski Master

          Ruben,

          How do you access bean property? There are no drag/drop listeners in the posted code.

          • 2. Re: Accessing param values using Drag n Drop
            Ruben Jorge Newbie

            nbelaevski, my drop component is defined as:

            <h:form style="margin-bottom:0;">
             <rich:dropSupport id="dropSupportTable"
             acceptedTypes="attribute,level,measure"
             dropListener="#{SessionBean.processDropSupportTable}"></rich:dropSupport>
            ...
            </h:form>
            


            Then in my bean I have the respective method:

             //dropped item processors
             public void processDropSupportTable(DropEvent dropEvent) {
             if (dropEvent.getDragType().compareTo("measure") == 0) {
             SOLAPMeasure dragged = (SOLAPMeasure)dropEvent.getDragValue();
             System.out.println("dropped: " + dragged.getId() + " named: " + dragged.getName() + " whose operator is: " + tempAggOp);
             }
             }
            


            I can access the object's properties (getId() and getName()) perfectly, but tempAggOp (the extra parameter) is firstly null and then it always has the value of the previous dragged object.

            • 3. Re: Accessing param values using Drag n Drop
              Ilya Shaikovsky Master

              try to use just f:param and take the parameter from request map yourself. probably this is just an common issue with action listeners. action param works as action listener so it fired just after parent component listener (works as declared in JSF spec)

              • 4. Re: Accessing param values using Drag n Drop
                Ruben Jorge Newbie

                Thank you very much ilya_shaikovsky. I did that and got it to work, here's the final code if anyone comes by with the same problem:

                On the drag support component:

                <rich:dragSupport dragIndicator=":indicator" dragType="measure" dragValue="#{measure}">
                 <f:param name="operator" value="#{aggOp}" />
                 <rich:dndParam name="label" value="#{measure.name} (#{aggOp})"/>
                </rich:dragSupport>
                


                On the backing bean:

                 //dropped item processors
                 public void processDropSupportTable(DropEvent dropEvent) {
                 if (dropEvent.getDragType().compareTo("measure") == 0) {
                 SOLAPMeasure dragged = (SOLAPMeasure)dropEvent.getDragValue();
                 FacesContext context = FacesContext.getCurrentInstance();
                 Map requestMap = context.getExternalContext().getRequestParameterMap();
                 String tempAggOp = (String)requestMap.get("operator");
                 System.out.println("dropped: " + dragged.getId() + " named: " + dragged.getName() + " whose operator is: " + tempAggOp);
                 }
                 }
                


                Thank you again.