Good points. I'll look into making the required JXPath objects serializable. Currently I don't see any serious problem with that.
- Dmitri --- Dmitry Sklyut <[EMAIL PROTECTED]> wrote: > Hi All, > > I am looking for the best approach in using JXpath in the following > situation. > > Here is the explanation of the requirements : > > I must have all of the data encapsulated in the java beans. Those > beans > must expose the following 3 APIs that accept Xpath expression to set, > get > and find data: > 1) set(path, object):void -> maps to createPathAndSetValue of > JXpathContext > 2) get(path):Object -> maps to getValue() > 3) find(path):Iterator -> maps to iterate() > > I am also must decouple the actual Xpath implementation from the core > system, so it can be switched on the fly. > These APIs are used by the custom tags on the JSPs to get the data > from the > beans by building XPath expressions. > Here is an example: > <form name="LoginForm" action="./loginHandler" method="POST"> > <tag:bean name="ParentBean" parent="true"> > <tag:bean name="Child1"> > <tag:input name="propterty1"/> > </tag:bean> > <tag:bean name="Child2"> > <tag:bean name="GrandChild1"> > <tag:input name="property"/> > <tag:bean> > </tag:bean> > </tag:bean> > </form> > > the above would render as: > <form name="LoginForm" action="./loginHandler" method="POST"> > <input type="hidden" name="PAGE_BEAN" value="ParentBean"/> > <input type="text" name="/Child1/propterty1"/> > <input type="test" name="/Child2/GrandChild1/property"/> > </form> > > User actions can span multiple page invocations (request) so > HttpSession is > used to save the conversational state. > Custom Tags get the beans from the HttpSession and render the page > with the > data from the beans, and ControllerServlet reads the Xpath from the > HttpServletRequest parameters and constructs/populates beans upon > submission > of the request. > > To achieve all of these requirements I must access JXpathContext > through a > interface exposed by my data beans (get/set/find). These beans also > must be > Serializable to be added to the HttpSession. So by wrapping > JXpathContext > in the my bean I can have the pathing API working. The problem is > that none > of the JXpath classes (except for the Pointers) are Serializable. > This > presents a problem when Serializing the bean. > > I see three solutions: > 1) Make wrapped JXpathContext transient and provide lazy > initialization of > the JXpathContext. > 2) Modify the code to add "implements Serializable" to most of the > JXpath > classes > 3) Create new JXpathContext object with each get/set/find API > invocation. > > So far only option 1 (one) looks appealing. > Option 2 - I don't want to change the JXpath code (lazy and not sure > of the > impact, plus I want to be able to grab the jar of the web when in a > jam > without too much copy/paste/compile). > Option 3 - Just not something I am willing to do. > > Are there any other approaches that anyone can suggest? Maybe there > is a > way to use Pointers or have only CompiledPaths? But in any case that > I seen > so far - there is always a need for JXpathContext object. > > Thanks for reading this far :) > > Dmitry > __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
