You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Eric Fixler <fi...@fixler.com> on 2004/11/11 19:28:05 UTC

AbstractSearchTool + Struts

Hi.  I'd like to use AbstractSearchTool (or it's apparently incipient 
replacements), and I'm also using Struts.  I think I understand all the 
individual pieces, but I'm missing part of the big picture, i.e. where 
does the SearchTool get instantiated.

Let's say I've done the following -

1) Subclassed AbstractSearchTool

2) Added an entry for it in the toolbox.xml

3) Set up a [struts] action called '/search'

4) Written a velocity template

How does (Or how would I make sure that) my SearchTool get 
instantiated, executed, and placed in the context at the key designated 
in the toolbox file?

If there's a doc page on this, please point me to it...

thanks
eric




---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


RE: AbstractSearchTool + Struts

Posted by Matthew Van Horn <ma...@ashleyassociates.co.jp>.
That's what I was talking about - I didn't realize it was in the CVS
already.

> -----Original Message-----
> From: Shinobu Kawai [mailto:shinobu.kawai@gmail.com] 
> Sent: Monday, November 15, 2004 4:40 PM
> To: Velocity Users List
> Subject: Re: AbstractSearchTool + Struts
> 
> 
> 
> Hi Matthew,
> 
> > I split the paging work from the search work into a different tool.
> > This may be more along the lines of what you want. I can 
> send you the
> > code, if you like, 
> > or you can work it out yourself - it is not that difficult.
> Could it be something like the AbstractPagerTool in the latest CVS?
>   
> http://cvs.apache.org/viewcvs.cgi/jakarta-velocity-tools/src/j
ava/org/apache/velocity/tools/view/tools/AbstractPagerTool.java?rev=1.1&
view=auto

Best regards,
-- Shinobu Kawai

--
Shinobu Kawai <sh...@gmail.com>


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: AbstractSearchTool + Struts

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Matthew,

> I split the paging work from the search work into a different tool. 
> This may be more along the lines of what you want. I can send you the
> code, if you like, 
> or you can work it out yourself - it is not that difficult.
Could it be something like the AbstractPagerTool in the latest CVS?
  http://cvs.apache.org/viewcvs.cgi/jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/tools/AbstractPagerTool.java?rev=1.1&view=auto

Best regards,
-- Shinobu Kawai

--
Shinobu Kawai <sh...@gmail.com>


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


RE: AbstractSearchTool + Struts

Posted by Matthew Van Horn <ma...@ashleyassociates.co.jp>.
I split the paging work from the search work into a different tool. 
This may be more along the lines of what you want. I can send you the
code, if you like, 
or you can work it out yourself - it is not that difficult.

> -----Original Message-----
> From: Eric Fixler [mailto:fix@fixler.com] 
> Sent: Friday, November 12, 2004 7:46 AM
> To: Velocity Users List
> Subject: Re: AbstractSearchTool + Struts
> 
> 
> Thanks Shinobu.
> 
> I think I didn't phrase what I was asking so well.  In my 
> understanding  
> of the way VelocityStruts works, a request goes
> 
> request->Struts Actions->VelocityViewServlet->vtl template
> 
> And what I really wanted to do was parse my query and manipulate my  
> AbstractSearchTool inside the relevant Struts Action, and then let  
> control get passed to VelocityViewServlet, etc.
> 
> I can see that VelocityViewServlet gets a ToolboxManager using  
> ServletToolboxManager.getInstance(servletContext, file), but there  
> doesn't seem to a way to share the tools easily elsewhere.
> 
> OTOH, looking at the docs again, maybe the way I pictured it 
> just isn't  
> the way to do it.  It looks like the only way to have interaction  
> between the Struts action and the tool is to do a  
> request.setAttribute() in the preceding action and then look for an  
> attribute in the tool's setup() method.
> 
> 
> thanks again, and sorry if I'm being thick
> eric
> 
> 
> 
> On Nov 11, 2004, at 1:39 PM, Shinobu Kawai wrote:
> 
> > Hi Eric,
> >
> >> Hi.  I'd like to use AbstractSearchTool (or it's 
> apparently incipient 
> >> replacements), and I'm also using Struts.  I think I understand all
> >> the
> >> individual pieces, but I'm missing part of the big 
> picture, i.e. where
> >> does the SearchTool get instantiated.
> >>
> >> Let's say I've done the following -
> >
> > ## snip
> >
> >> How does (Or how would I make sure that) my SearchTool get 
> >> instantiated, executed, and placed in the context at the key
> >> designated
> >> in the toolbox file?
> >>
> >> If there's a doc page on this, please point me to it...
> > AbstractSearchTool is the same as any other tool.
> >    
> > http://jakarta.apache.org/velocity/tools/view/
> > index.html#Toolbox%20Configuration
> >
> > For an example of toolbox.xml entry,
> >    
> > 
> http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocit>
y/
> > tools/view/tools/AbstractSearchTool.html
> >
> > For the actual code,
> >    
> > 
> http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocit>
y/
> > tools/view/servlet/ 
> > VelocityViewServlet.html#initToolbox(javax.servlet.ServletConfig)
> >    
> > 
> http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocit>
y/
> > tools/view/ViewToolInfo.html#getInstance(java.lang.Object)
> >
> > Best regards,
> > -- Shinobu Kawai
> >
> > --
> > Shinobu Kawai <sh...@gmail.com>
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: 
> velocity-user-help@jakarta.apache.org
> >
> >
> ---------------------------------------------------------------------
> Eric Fixler
> fix@fixler.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: AbstractSearchTool + Struts

Posted by Eric Fixler <fi...@fixler.com>.
Thanks Shinobu.

I think I didn't phrase what I was asking so well.  In my understanding  
of the way VelocityStruts works, a request goes

request->Struts Actions->VelocityViewServlet->vtl template

And what I really wanted to do was parse my query and manipulate my  
AbstractSearchTool inside the relevant Struts Action, and then let  
control get passed to VelocityViewServlet, etc.

I can see that VelocityViewServlet gets a ToolboxManager using  
ServletToolboxManager.getInstance(servletContext, file), but there  
doesn't seem to a way to share the tools easily elsewhere.

OTOH, looking at the docs again, maybe the way I pictured it just isn't  
the way to do it.  It looks like the only way to have interaction  
between the Struts action and the tool is to do a  
request.setAttribute() in the preceding action and then look for an  
attribute in the tool's setup() method.


thanks again, and sorry if I'm being thick
eric



On Nov 11, 2004, at 1:39 PM, Shinobu Kawai wrote:

> Hi Eric,
>
>> Hi.  I'd like to use AbstractSearchTool (or it's apparently incipient
>> replacements), and I'm also using Struts.  I think I understand all  
>> the
>> individual pieces, but I'm missing part of the big picture, i.e. where
>> does the SearchTool get instantiated.
>>
>> Let's say I've done the following -
>
> ## snip
>
>> How does (Or how would I make sure that) my SearchTool get
>> instantiated, executed, and placed in the context at the key  
>> designated
>> in the toolbox file?
>>
>> If there's a doc page on this, please point me to it...
> AbstractSearchTool is the same as any other tool.
>    
> http://jakarta.apache.org/velocity/tools/view/ 
> index.html#Toolbox%20Configuration
>
> For an example of toolbox.xml entry,
>    
> http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/ 
> tools/view/tools/AbstractSearchTool.html
>
> For the actual code,
>    
> http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/ 
> tools/view/servlet/ 
> VelocityViewServlet.html#initToolbox(javax.servlet.ServletConfig)
>    
> http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/ 
> tools/view/ViewToolInfo.html#getInstance(java.lang.Object)
>
> Best regards,
> -- Shinobu Kawai
>
> -- 
> Shinobu Kawai <sh...@gmail.com>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
Eric Fixler
fix@fixler.com


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: AbstractSearchTool + Struts

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Eric,

> Hi.  I'd like to use AbstractSearchTool (or it's apparently incipient
> replacements), and I'm also using Struts.  I think I understand all the
> individual pieces, but I'm missing part of the big picture, i.e. where
> does the SearchTool get instantiated.
> 
> Let's say I've done the following -

## snip

> How does (Or how would I make sure that) my SearchTool get
> instantiated, executed, and placed in the context at the key designated
> in the toolbox file?
> 
> If there's a doc page on this, please point me to it...
AbstractSearchTool is the same as any other tool.
  http://jakarta.apache.org/velocity/tools/view/index.html#Toolbox%20Configuration

For an example of toolbox.xml entry,
  http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/view/tools/AbstractSearchTool.html

For the actual code,
  http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/view/servlet/VelocityViewServlet.html#initToolbox(javax.servlet.ServletConfig)
  http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/view/ViewToolInfo.html#getInstance(java.lang.Object)

Best regards,
-- Shinobu Kawai

-- 
Shinobu Kawai <sh...@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org