Ivelin,

I'm trying to code your suggestions but I have problems and some doubts.

> 1) You can remove ArtistBean altogether
Done.

> 2) Store the empty id structure in a static file or local constant
Done.

> 3) Override the getForm() method in the action
Wouldn't it be enough to override the getFormModel() method?
Something like this:
  protected Object getFormModel() {
 //to load the XML model
 Container DOMModel = null;
 Source modelSrc = null;
   //this parameter holds the name of the xml file with the empty XML
structure
    String modelFileName = getParameters().getParameter("xmlform-model",
null);
    if(modelFileName==null) return null;
    try {
     modelSrc = getSourceResolver().resolveURI(modelFileName);
  DOMModel = new XMLDocumentContainer(new
StreamSource(modelSrc.getInputStream()));
        return DOMModel;
      }
      catch ( Exception e) {
        throw new CascadingRuntimeException( " Failed instantiating form
model ", e );
      }
      finally {
        getSourceResolver().release(modelSrc);
      }
  }

> 4) Use the JXPath DOMContainer to load the xml file(constant)
I have used XMLDocumentContainer. I see there's a DocumentContainer but only
present in JXPath 1.1 alpha and the jar file is still not included in
Cocoon, so I used the soon to be deprecated mentioned.
Btw, how could I extract a DOMNode from the root or an XML String so I could
store the whole structure afterwards? I see in 1.1alpha I could do something
like 'DocumentContainer.MODEL_DOM' but I guess in 1.0 I should get a
JXPathContext and search for the root node so I can get the String I need.
Am I right?

> 5) Use the DOMContainer object as the Form model
Ok. But where should I store it? In a separate file like the ArtistBean I
got before?
Or maybe would be enough to declare it and initialize it in the getForm() or
getFormModel() method?

> 6) When you need to reference a node in the model, instead of using the
DOM
> API, you can directly use XPath,
> like this: getForm().getValue("/@id")
At this stage I can only see the form and when trying to access the model I
get the following exception: 'Cannot setValue of an object that is not some
other object's property/child'

Sorry about all the questions but this is totally new for me and it is not
easy.

Best.





---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to