Hey Alan By all means try experimenting with the code and see where it takes you ;-)
One way this might work could be, we could use XPath to find a Node for each cell in the table, then when editing occurs then the setText() method could be called on it. So a cell could be editable if the XPath expression finds a single Node. The more I think of this, the more I like it. So the XPath expressions just find the Node that matches a cell in the table - then editing could be supported pretty easily. Alan, do you fancy having a go at hacking the TableModel to implement this? James ----- Original Message ----- From: "Alan O'Leary" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, February 26, 2002 2:45 PM Subject: RE: [dom4j-user] TableModel. > Hello, > Thanks for the response. I understand the restriction of using > XPath for updates now. However I am wondering if there is an > intermediate step that I can achieve table editing. Basically the method > of using a 'TableTemplate' is what I find most useful. > > I am wondering if it would be possible for me through the use of > extending/customising the TableDefinition/Column definitions classes to > be able to handle editing in the tablemodel set up using the current > mechanism. > > I mean could I get an XPath expression that indicates the current cell I > am in and use that expression to GET the Element/Node in the document > that this cell represents so that I can then modify it directly.... > > > i.e. XMLTableModel.java > > 1) override isCellEditable to return true... > 2) override setValueAt(Object aValue, int rowIndex, int columnIndex) > > Now in this method > Object row = getRowValue(rowIndex); > Object cell = definition.getValueAt(row, columnIndex); > > But how can I find out / map back to what this cell means in the > original document... ? > > > > > > Thanks in advance, > -Alan > > -----Original Message----- > From: James Strachan [mailto:[EMAIL PROTECTED]] > Sent: 22 February 2002 00:32 > To: Alan O'Leary; [EMAIL PROTECTED] > Subject: Re: [dom4j-user] TableModel. > > Hey Alan > > Displaying the table using XPath expressions is pretty easy. Right now > though updating a document via an XPath expression is pretty hard stuff. > XPath is generally used to evaluate expressions on existing documents - > its > rarely used to actually update documents 'in place'. > > Though I think it'd be cool to support a subset of XPath for update > purposes. Quite a few people seem to want this feature. e.g. you could > do > something like > > update( document, "/foo/bar/@x", "Some value" ); > > For some xpath expressions this makes sense, though for others like > 'count(/foo/bar)' don't make sense though. It'd take some hacking to get > the > Jaxen XPath engine to be able to support this but it would be kinda cool > if > we could do this. > > James > ----- Original Message ----- > From: "Alan O'Leary" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, February 21, 2002 9:30 AM > Subject: [dom4j-user] TableModel. > > > > Hello, > > I am currently looking at the new TableModel approach that is in > > the latest release. I am trying to extend this TableDemo example to > make > > it editable etc... > > > > This is as a Swing/<dom4j> learning exercise... > > > > What I have set up is a Tree and Table and the Tree uses the tree > model > > and on node selection the 'branch' of the tree is used to display a > > table (using a table definition) > > > > All this works now BUT I when I edit a cell I cannot get back a node > > within the document... > > > > (Basically I am building a little XML editor as I thought that would > be > > a good way to learn this stuff quickly) > > > > What I am wondering is that I have access to a Row XPath and Column > > XPath expression .... > > > > Is this the key or is there a better way ? > > > > So I have overridden the : > > > > 'public void setValueAt(Object aValue, int rowIndex, int columnIndex)' > > > > but don't know how to modify / access the correct cell the document... > > > > Any help appreciated ... > > > > Basically I would like to use the TableDefinition approach rather than > > hard coding a table model... > > > > Regards > > Alan > > > > > > _______________________________________________ > > dom4j-user mailing list > > [EMAIL PROTECTED] > > https://lists.sourceforge.net/lists/listinfo/dom4j-user > > > > _______________________________________________ > dom4j-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/dom4j-user _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user