cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jiri Luzny <jiri_lu...@yahoo.com>
Subject Re: "redirect-to resource" and substitution of the List of Maps
Date Fri, 18 May 2001 12:18:18 GMT
dims,

I has actually tried the split already, but there is an issue. The resource_ method is declared
as
private, so AbstractSitemap.java (as super class) doesn't have access to the method. Only
way to
move this method to AbstractSitemap.java is to make the  resource_ method public.

Jiri.


--- Davanum Srinivas <dims@yahoo.com> wrote:
> Jiri,
> 
> I split your patch into two pieces, moved the invokeMethod into AbstractSitemap.java
and kept
> the
> other one in sitemap.xsl where it belongs. Please try it out.
> 
> Thanks,
> dims
> 
> --- Jiri Luzny <jiri_luzny@yahoo.com> wrote:
> > Hi Folks,
> > 
> > nobody has replied to my previous e-mail, so it means that you agree with the way
how I solved
> > the
> > issue ;-)
> > The patch is included.
> > 
> > Jiri.
> > 
> > 
> > 
> > >Here is the working solution:
> > 
> > ><!-- redirect to a internal resource definition -->
> > ><xsl:when test="@resource">
> > >  Class[] argTypes = new Class[] {StreamPipeline.class, EventPipeline.class,
List.class,
> > >Environment.class, String.class, Boolean.TYPE};
> > >  Object[] argValues = new Object[] {pipeline, eventPipeline, listOfMaps, environment,
> > >cocoon_view, new Boolean(internalRequest)};
> > >  String methodName = "resource_" + substitute(listOfMaps, "<xsl:value-of
> > >select="translate(@resource, '- ', '__')"/>");
> > >  java.lang.reflect.Method  method = this.getClass().getDeclaredMethod(methodName,
argTypes);
> > >  if(true)return ((Boolean) method.invoke(this, argValues)).booleanValue();
> > ></xsl:when>
> > >
> > >
> > >It is small portion of Java Reflection. I'm curious if it is acceptable for
you guys :)
> > >I don't see any problem of using it. It would actually used for other dynamic
method
> > >invocations like view_ etc.(if it makes sence). It would be also moved to a
helper
> > method/class...
> > >
> > >Jiri.
> > >
> > >
> > >>giacomo,
> > >>
> > >>the reason of the namespace tests is OK (it is logical). However, as you
mentioned the
> actual
> > >>reason why map:redirect-to resource="..."> are not substitutable is that
you have to create
> a
> > >>dynamic call to a generated resource_ method:
> > >
> > >>sitemap.xsl:995,7
> > >><!-- redirect to a internal resource definition -->
> > >><xsl:when test="@resource">
> > >>  if(true)return resource_<xsl:value-of select="translate(@resource,
'- ',
> '__')"/>(pipeline,
> > >>eventPipeline, listOfMaps, environment, cocoon_view, internalRequest);
> > >></xsl:when>
> > >>
> > >>
> > >>
> > >>To implement the required substitution it must be changed to something like
this:
> > >>
> > >><!-- redirect to a internal resource definition -->
> > >><xsl:when test="@resource">
> > >>  <xsl:variable name="resourceSubstituted"><xsl:value-of select="java:substitute(listOfMaps,
> > >>@resource)"/></xsl:variable>
> > >>  if(true)return resource_<xsl:value-of select="$resourceSubstituted"/>"(pipeline,
> > eventPipeline,
> > >>listOfMaps, environment, cocoon_view, internalRequest);
> > >></xsl:when>
> > >>
> > >>
> > >>It is just a clue and it is obvious it won't work. I will be trying to find
a working
> > solution,
> > >>but maybe someone knows it already ;-) ...
> > >>
> > >>
> > >>Jiri.
> > >
> > >
> > >
> > >--- giacomo <giacomo@apache.org> wrote:
> > >> 
> > >> 
> > >> On Tue, 15 May 2001, Marcus Crafter wrote:
> > >> 
> > > > Hi Jiri,
> > > >
> > > > 	See my email from last week at:
> > > >
> > > > 	http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=98961067308100&w=2
> > > >
> > > > 	There seems to be a problem with the action generation code when it
> > > > 	tests for what namespace the sitemap is in. This causes the generated
> > > > 	map:act code not to add the returned Map object to listOfMaps.
> > > >
> > > > 	I'm not 100% sure of whether its a bug, or a feature and I've
> > > > 	misunderstood the namespace check. Have a look at sitemap.xsl, line
> > > > 	684:
> > > >
> > > > <xsl:when test="./*[namespace-uri()='http://apache.org/cocoon/sitemap/1.0']">
> > > 
> > > IIRC the reason doing that was to check if there a <map:* ..> elements
> > > insite the <map:act ...> element to know if we need to push the returned
> > > map or not.
> > > 
> > > A snippet like this:
> > > 
> > >    <map:act type="..."/>
> > > 
> > > doesn't need to push the returned map into the listOfMaps because no one
> > > will actually use it. But
> > > 
> > >    <map:act type="...">
> > >      <map:...   >
> > >    </map:act>
> > > 
> > > instead must make the returned map from the Action available for the
> > > content of the <map:act ...> element.
> > > 
> > > Giacomo
> > > 
> > > >
> > > > 	I'm not exactly sure why this test is there ? But it is what's causing
> > > > 	the noted behaviour.
> > > >
> > > > 	You can get the behaviour you're expecting by adding:
> > > >
> > > > 	listOfMaps.add (map);
> > > >
> > > > 	after line 693 in sitemap.xsl, but that's strictly a workaround, and
> > > > 	not a fix.
> > > >
> > > > 	Hopefully some of the more sitemap.xsl savvy developers might be able
> > > > 	to shed some light here. :-)
> > > >
> > > > 	Cheers,
> > > >
> > > > 	Marcus
> > > >
> > > > On Tue, 15 May 2001, Jiri Luzny wrote:
> > > >
> > > > > I'm tried to the following redirection using a sitemap parameter
from an action and it
> > > doesn't
> > > > > work:
> > > > >
> > > > > ------
> > > > > <map:match pattern="foo">
> > > > >   <map:act type="some-validator">
> > > > >     <map:redirect-to resource="foo-{next}"/>
> > > > >   </map:act>
> > > > > </map:match>
> > > > >
> > > > > <map:resource name="foo-second">
> > > > > ..
> > > > > ..
> > > > > </map:resource>
> > > > > -------
> > > > >
> > > > > For "uri" redirection:
> > > > > -----
> > > > > <map:redirect-to uri="foo-{next}"/>
> > > > > -----
> > > > > it works without any problem.
> > > > >
> > > > > I took look at sitemap.xsl and it seems that the substitution of
the List of Maps is not
> > > > > implemented for "resource" type of the redirection. Why? I think
it is useful as well...
> > > > >
> > > > > Jiri.
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Auctions - buy the things you want at great prices
> > http://auctions.yahoo.com/> Index: sitemap.xsl
> > ===================================================================
> > RCS file:
> >
>
/home/cvspublic/xml-cocoon2/src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl,v
> > retrieving revision 1.2
> > diff -r1.2 sitemap.xsl
> > 113a114,132
> > >       
> > >       /**
> > >        * Invokes a method of this class using Java Reflection
> > >        *
> > >        * @param methodName The name of the method to be invoked
> > >        * @param argTypes The array of class types of the method attributes
> > >        * @param argTypes The array of values of the method attributes
> > >        *
> > >        * @exception Exception If an error occurs during method invocation
> > >        */
> > >       private boolean invokeMethod(String methodName, Class[] argTypes, Object[]
argValues)
> > throws Exception {
> > >         try {
> > >           java.lang.reflect.Method method = this.getClass().getDeclaredMethod(methodName,
> > argTypes);
> > >           return ((Boolean) method.invoke(this, argValues)).booleanValue();
> > >         } catch (Exception e) {
> > >           throw new Exception ("Sitemap: " + methodName + " not found");
> > >         }
> > >       }
> > > 
> > 997c1016,1019
> > <         if(true)return resource_<xsl:value-of select="translate(@resource,
'- ',
> > '__')"/>(pipeline, eventPipeline, listOfMaps, environment, cocoon_view, internalRequest);
> > ---
> > >         Class[] argTypes = new Class[] {StreamPipeline.class, EventPipeline.class,
> List.class,
> > Environment.class, String.class, Boolean.TYPE};
> > >         Object[] argValues = new Object[] {pipeline, eventPipeline, listOfMaps,
environment,
> > cocoon_view, new Boolean(internalRequest)};
> > >         String methodName = "resource_" + substitute(listOfMaps, "<xsl:value-of
> > select="translate(@resource, '- ', '__')"/>");
> > >         if(true)return invokeMethod(methodName, argTypes, argValues);
> > 
> > > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> > For additional commands, email: cocoon-dev-help@xml.apache.org
> 
> 
> =====
> Davanum Srinivas, JNI-FAQ Manager
> http://www.jGuru.com/faq/JNI
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great prices
> http://auctions.yahoo.com/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message