Menu

#1 DndDiv.xhtml incorrect

open
dnd (2)
5
2010-04-07
2010-03-27
No

missing a closing tag of the first "div" (and only) of template

my server shows the following error:

javax.servlet.ServletException: Error Parsing //C:/Program%20Files%20(x86)/jboss-5.1.0.GA/server/default/deploy/Sergas.war/WEB-INF/lib/dojo-faces-1.2_02.jar/META-INF/tags/DndDiv.xhtml: Error Traced[line: 65] The element type "div" must be terminated by the matching end-tag "</div>".

Discussion

  • Alberto Fernández

    DndStoreMap

     
  • Alberto Fernández

    I've noticed that the functionality is not implemented.
    Here I post a simple solution.

    At dojoHelper.java add:

    public DndStoreMap getDndStore() {
    return new DndStoreMap();
    }

    Copy attached files:
    DndStoreMap.java -> org.j4fry.dojo.beans
    DndDiv.xhtml -> META-INF/tags

    It's all.

    Simple working example:

    At foo.xhtml, whitin dojo:form:

    <dojo:dndDiv id="srcVegetales" type="source" styleClass="dndContainer"
    items="\#{testFormBean.vegetales}" key="\#{item.name}" var="item" attr="" />

    <dojo:dndDiv id="dstVegetales" type="target" styleClass="dndContainer"
    items="\#{testFormBean.dndVegetales}" key="\#{item.name}" var="item" attr="" />
    <!-- insertClass="es.atos.test.domain.Vegetal" -->

    At fooBean.java:

    // source
    public List<Vegetal> getVegetales() {
    return vegetales.getVegetales();
    }

    // target

    private List<Vegetal> dndVegetales;

    public void setDndVegetales(List<Object> dndVegetales) {
    logger.info("fijando vegetales = " + dndVegetales);
    HashMap<String, Vegetal> vegetalesMap = (HashMap<String, Vegetal>) vegetales.getVegetalesMap();
    this.dndVegetales = new ArrayList<Vegetal>();
    for (Object o : dndVegetales) {
    if (o instanceof Vegetal) { // insertClass is set
    this.dndVegetales.add(vegetalesMap.get(((Vegetal) o).getName()));
    } else if (o instanceof String) { // insertClass is not set
    this.dndVegetales.add(vegetalesMap.get((String) o));
    }
    }
    }

    public List<Vegetal> getDndVegetales() {
    return dndVegetales;
    }

    Notes:
    * if insertClass is set, then the objects passed to setter are instances of the
    type declared in that param
    * if no key param is defined, then assumes the list is of type List<String>, don't use
    insertClass in that case
    * the dndDiv not allow to insert duplicates

     
  • Alberto Fernández

    DndDiv

     
  • Alberto Fernández

    DndDiv (rev. 2)

     
  • Alberto Fernández

    DndStoreMap (rev. 2)

     
  • Alberto Fernández

    Rev 2 : improvement in order to indicate the property of the object to be displayed in the dndDiv container (by default -if not present mapValue parameter- shows key property) (when using lists of user objects, not string list); parameter key is now mapKey; new parameter mapValue

    Example (List<Vegetal>) ----------------------------------

    <dojo:dndDiv id="srcVegetales" type="source" styleClass="dndContainer"
    items="\#{testFormBean.srcDndVegetales}" mapKey="\#{item.id}" mapValue="\#{item.name}" var="item" insertClass="es.atos.test.domain.Vegetal" attr="" />

    <dojo:dndDiv id="dstVegetales" type="target" styleClass="dndContainer"
    items="\#{testFormBean.dstDndVegetales}" mapKey="\#{item.id}" mapValue="\#{item.name}" var="item" insertClass="es.atos.test.domain.Vegetal" attr="" />

    public void setSrcDndVegetales(List<Object> srcDndVegetales) {
    this.srcDndVegetales = new ArrayList<Vegetal>();
    for (Object o : srcDndVegetales) {
    if (o instanceof Vegetal) { // insertClass is set
    this.srcDndVegetales.add(vegetales.findById(((Vegetal) o).getId()));
    } else if (o instanceof String) { // insertClass is not set
    this.srcDndVegetales.add(vegetales.findById((String) o));
    }
    }
    }

    public List<Vegetal> getSrcDndVegetales() {
    if (this.srcDndVegetales == null) {
    this.srcDndVegetales = new ArrayList<Vegetal>(vegetales.getVegetalesMap().values());
    }
    return this.srcDndVegetales;
    }

    public void setDstDndVegetales(List<Object> dndVegetales) {
    logger.info("fijando vegetales destino = " + dndVegetales);
    this.dstDndVegetales = new ArrayList<Vegetal>();
    for (Object o : dndVegetales) {
    if (o instanceof Vegetal) {
    this.dstDndVegetales.add(vegetales.findById(((Vegetal) o).getId()));
    } else if (o instanceof String) {
    this.dstDndVegetales.add(vegetales.findById((String) o));
    }
    }
    }

    public List<Vegetal> getDstDndVegetales() {
    return dstDndVegetales;
    }

    Example (List<String>) -------------------------

    <dojo:dndDiv id="srcVegetalesStr" type="source" styleClass="dndContainer"
    items="\#{testFormBean.srcDndVegetalesStr}" var="item" attr="" />

    <dojo:dndDiv id="dstVegetalesStr" type="target" styleClass="dndContainer"
    items="\#{testFormBean.dstDndVegetalesStr}" var="item" attr="" />

    public void setSrcDndVegetalesStr(List<Object> srcDndVegetales) {
    this.srcDndVegetalesStr = new ArrayList<String>();
    for (Object o : srcDndVegetales) {
    if (o instanceof Vegetal) { // insertClass is set
    this.srcDndVegetalesStr.add(((Vegetal) o).getName());
    } else if (o instanceof String) { // insertClass is not set
    this.srcDndVegetalesStr.add((String) o);
    }
    }
    }

    public List<String> getSrcDndVegetalesStr() {
    if (this.srcDndVegetalesStr == null) {
    this.srcDndVegetalesStr = vegetales.getVegetalesNames();
    }
    return this.srcDndVegetalesStr;
    }

    public void setDstDndVegetalesStr(List<Object> dndVegetales) {
    this.dstDndVegetalesStr = new ArrayList<String>();
    for (Object o : dndVegetales) {
    if (o instanceof Vegetal) {
    this.dstDndVegetalesStr.add(((Vegetal) o).getName());
    } else if (o instanceof String) {
    this.dstDndVegetalesStr.add((String) o);
    }
    }
    }

    public List<String> getDstDndVegetalesStr() {
    return dstDndVegetalesStr;
    }

     
  • Alberto Fernández

    DndDiv (rev. 3)

     
  • Alberto Fernández

    In the third revision of DndDiv.xhtml, we can now define the type of items accepted by a dndDiv container, through the parameter "accept" (ej accept="vegetal,animal")
    Typically for containers that act as target.

    The parameter "nodeType" allow to define type of nodes which contains a dndDiv. Typically for sources.

    Example:

    <dojo:dndDiv id="srcVegetales" type="source" nodeType="vegetal" styleClass="dndContainer" items="\#{testFormBean.srcDndVegetales}" mapKey="\#{item.id}" mapValue="\#{item.name}" var="item" insertClass="es.atos.test.domain.Vegetal" attr="" />

    <dojo:dndDiv id="dstVegetales" type="target" accept="vegetal" styleClass="dndContainer" items="\#{testFormBean.dstDndVegetales}" mapKey="\#{item.id}" mapValue="\#{item.name}" var="item" insertClass="es.atos.test.domain.Vegetal" attr="" />

    <dojo:dndDiv id="srcVegetalesStr" type="source" nodeType="otroVegetal" styleClass="dndContainer" items="\#{testFormBean.srcDndVegetalesStr}" var="item" attr="" />

    <dojo:dndDiv id="dstVegetalesStr" type="target" accept="otroVegetal" styleClass="dndContainer" items="\#{testFormBean.dstDndVegetalesStr}" var="item" attr="" />

     
  • ganesh

    ganesh - 2010-04-07
    • labels: --> dnd
     
  • ganesh

    ganesh - 2010-04-07
    • assigned_to: nobody --> alfdez
     
  • Alberto Fernández

    showRoom dnd.xhtml (example)

     
  • Alberto Fernández

    beans DndBean (example)

     
  • Alberto Fernández

    Example to add to JSFExamples:

    1) Copy DndBean.java to package org.j4fry.beans
    2) Copy dnd.xhtml to WebContent/showRoom
    3) Modify common.xhtml and add the following line in a appropiate place (around line 90):

    <a href="${request.contextPath}/showRoom/dnd.faces" target="_self" class="fishMenu">Dnd</a><br />

    4) I've also modified class Car at package org.j4fry.domain, adding this two methods, to get and set an extended description of the car (in this example de setter should be, but it is not necessary to do something)

    public void setLongDescription(String longDescription) {
    // nothing
    }
    public String getLongDescription() {
    return String.format("%s (%s mph)", getName(), getSpeed());
    }

     

Log in to post a comment.