Hi all,

i am having troubles with the validation of some vortex (cells) in my project. I have custom objects when creating my vertex, and it does it very well:

  Celda pregunta = new Pregunta();
Object v1 = graph.insertVertex(parent, null, pregunta, 20, 20, 80, 30, pregunta.getPropiedades());

but the problem is when inserting the mxMultiplicity:

mxMultiplicity[] multiplicities = new mxMultiplicity[3];

multiplicities[0] = new mxMultiplicity(true, ((mxCell)v1).getValue().toString(), null, null, 1,
                null, Arrays.asList(new String[] { "Respuesta", "Estrategia" }),
                "Source Must Have 1 or 2 Targets",
                "Source Must Connect to Target", true);

The secon parameter is a string, but i dont know how i can put it into the mxMultiplicity constructor, I've tried "Pregunta" , ((mxCell)v1).getValue().toString()...etc.

Any ideas??


asked 23 Oct '12, 13:03

walolinux's gravatar image

accept rate: 0%

From debugging I get that getCellValidationError(Object cell) is called and within that this is called:

 * Returns true if the given value is an XML node with the node name and if
 * the optional attribute has the specified value.
 * @param value
 *            Object that should be examined as a node.
 * @param nodeName
 *            String that specifies the node name.
 * @param attributeName
 *            Optional attribute name to check.
 * @param attributeValue
 *            Optional attribute value to check.
 * @return Returns true if the value matches the given conditions.
public static boolean isNode(Object value, String nodeName,
        String attributeName, String attributeValue)
    if (value instanceof Element)
        Element element = (Element) value;

        if (nodeName == null
                || element.getNodeName().equalsIgnoreCase(nodeName))
            String tmp = (attributeName != null) ? element
                    .getAttribute(attributeName) : null;

            return attributeName == null
                    || (tmp != null && tmp.equals(attributeValue));

    return false;

It seems like the validation works only for XML.

I created this for you: http://forum.jgraph.com/questions/5222/custom-graph-validation


answered 23 Oct '12, 23:58

Lofi's gravatar image

accept rate: 37%

edited 24 Oct '12, 01:29

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 23 Oct '12, 13:03

Seen: 1,221 times

Last updated: 24 Oct '12, 01:29