Re: MVC2 way to stick a collection in page scope?

2003-08-15 Thread jack beany
Thanks for the offer Keith :)

Seems to be like getting blood from many stones at times hehe.  Not sure if 
I want to venture into pure EJB's just yet - think I'll just code it how I'm 
comfortable, using frameworks as and when I need.

Dont spose you know the answer to the question below, gone awfully quiet 
round here? ;)

Cheers

From: Keith Pemberton <[EMAIL PROTECTED]>
I too am working on my own blogging site but I'm using EJBs instead of
DAO objects.  What I did was to create a plugin that is specified in the
struts-config file.  The plugin interface is really easy to implement,
but you put the object in the ServletContext instead of page context.  I
can provide you a code sample if you need it.  I'm grabbing the last
five entries from the database using a Session bean interacting with
entity beans.  This is not the best way to implement a blogging system I
know, but it gives me a good excuse to learn some of the ins and outs of
Enterprise JavaBeans.  Anyway, let me know if I can help further.
On Thu, 2003-08-14 at 09:12, jack beany wrote:
> >From: Vic Cekvenich <[EMAIL PROTECTED]>
> >
> >jack beany wrote:
> >
> >>yup... so i have my Blog bean which calls the DAO for persistance.  
What I
> >>want to know is how to best structure the searching for a bunch of 
blog
> >>beans/records/objects, and then stick that in page scope for 
presentation
> >>with JSTL?
> >>
> >
> >Conder a Struts book, such as Struts in Acton.
> >Struts says this should be done in action.
> >The searching/retrieving happens in DAO.
> >Struts puts in in scope for you if updetable. Else, put it in request 
scope
> >(do so in Action) for JSTL.
>
> ok - getting closer...
>
> to summarise, you're saying I should have an index.do instead of an
> index.jsp and declare all bean/bean collections in the action.
>
> Currently I've not used an action without it being the result of a form
> posting... Do I just create an action mapping without a "name" 
attribute,
> and with an "attribute" attribute of something like "indexPage"? i.e.:
>
> 
>type="project.actions.IndexAction"
>   attribute="indexPage"
>   scope="request"
>validate="false">
> 
>
> then put a check for the indexPage scope in the jsp and redirect to the
> action if it doesnt exist?
_
Express yourself with cool emoticons - download MSN Messenger today! 
http://www.msn.co.uk/messenger

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


MVC2 way to stick a collection in page scope?

2003-08-14 Thread jack beany
Hi All,

I have my index page, and want a blog on it.  Blog entries are in a table, 
and I have all the db query side sorted out.  What I want to know is the 
best practice way of making a DAO which can be called from my index page and 
also from my findblog action.

The index page would pass a few logic/hard coded parameters to the bean, as 
would the findblog action.

I imagine I dont want to create an action for this as the blog is just one 
of half a dozen components on the page, and passive in nature (unlike with 
findblog action which is only thing on page and requiring form input).  I 
dont want to code sql in jsp, which would be fastest but messy.  I am not 
sure it's good practice to make a custom tag for this, to set my Result 
collection in page scope.  Perhaps a DAO bean to do the query and return a 
Result collection, which could then be put into correct scope by both the 
action and a new tag?

Thoughts?

Thanks

_
It's fast, it's easy and it's free. Get MSN Messenger today! 
http://www.msn.co.uk/messenger

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


Re: PropertyUtils.copyProperties and DynaValidatorForm

2003-08-14 Thread jack beany
Hi Adam,

From: Adam Hardy <[EMAIL PROTECTED]>
Yes that's the way to populate the DVForm. If you need a form the easiest 
way to instantiate it is to make sure it is set in the struts-config.xml
form = new DynaValidatorForm();
Any idea why this leaves form=null?  The form I'm going to populate is 
defined in the struts config file.  Could you provide a small code snippet 
that would go in the execute method?

Thanks
J.
_
Tired of 56k? Get a FREE BT Broadband connection 
http://www.msn.co.uk/specials/btbroadband

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


Re: MVC2 way to stick a collection in page scope?

2003-08-14 Thread jack beany
From: Vic Cekvenich <[EMAIL PROTECTED]>
In an MVC one does not cache data (results) in a view (jsp)
Model is for data layer, and data caching goes in model.
A DAO like iBatis or Hibrenate has configurable auto cache.
iBatis certainly looks good... Currently using JNDI, but this could save 
hassle in long term...

Of course, you do not call the DAO from the page. You could call the DAO 
from a bean.
yup... so i have my Blog bean which calls the DAO for persistance.  What I 
want to know is how to best structure the searching for a bunch of blog 
beans/records/objects, and then stick that in page scope for presentation 
with JSTL?

One should avoid custom tags now a days... with JSTL and all.
Can understand that!

Here is a similar example page:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/basicportal/bPproj/bP/WEB-INF/portlets/newsBlg/NewsBlgCmntsLst.jsp
thanks, probably going to use the ibatis examples too.

J

_
On the move? Get Hotmail on your mobile phone http://www.msn.co.uk/msnmobile
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: MVC2 way to stick a collection in page scope?

2003-08-14 Thread jack beany
From: Vic Cekvenich <[EMAIL PROTECTED]>

jack beany wrote:

yup... so i have my Blog bean which calls the DAO for persistance.  What I 
want to know is how to best structure the searching for a bunch of blog 
beans/records/objects, and then stick that in page scope for presentation 
with JSTL?

Conder a Struts book, such as Struts in Acton.
Struts says this should be done in action.
The searching/retrieving happens in DAO.
Struts puts in in scope for you if updetable. Else, put it in request scope 
(do so in Action) for JSTL.
ok - getting closer...

to summarise, you're saying I should have an index.do instead of an 
index.jsp and declare all bean/bean collections in the action.

Currently I've not used an action without it being the result of a form 
posting... Do I just create an action mapping without a "name" attribute, 
and with an "attribute" attribute of something like "indexPage"? i.e.:

   
   
then put a check for the indexPage scope in the jsp and redirect to the 
action if it doesnt exist?

Cheers
J
_
Hotmail messages direct to your mobile phone http://www.msn.co.uk/msnmobile
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RowSetDynaClass - iterating the dynabean collection properly

2003-08-14 Thread jack beany
Hi,

I have a bean collection passed back to a jsp from a
RowSetDynaClass.
jsp has the following code to loop through each dynabean in the collection
   

   
   
 
   
I get the exception:

[ServletException in:/findperson.jsp] An error occurred while
evaluating custom action attribute "value" with value
"${person.seq}": Unable to find a value for "seq" in object
of class "org.apache.commons.beanutils.BasicDynaBean" using
operator "." (null)' javax.servlet.ServletException: An error
occurred while evaluating custom action attribute "value"
with value "${person.seq}": Unable to find a value for "seq"
in object of class
"org.apache.commons.beanutils.BasicDynaBean" using operator
"." (null) at
org.apache.jasper.runtime.PageContextImpl.handlePageException
(PageContextImpl.java:533) at
if I just do  I get:
org.apache.commons.beanutils.BasicDynaBean
which is what I'd expect.
My previous, Struts taglib based, code works fine, but becomes a pain in the 
rear when I want to nest my nested tag inside a html:link or similar:

   
 
   
   

 
   
Any ideas what's wrong, or better still, what is the preferred method for 
looping through a RowSetDynaClass produced collection to produce a page of 
links to an edit action?

Thanks!
Jack
_
Tired of 56k? Get a FREE BT Broadband connection 
http://www.msn.co.uk/specials/btbroadband

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


PropertyUtils.copyProperties and DynaValidatorForm

2003-08-14 Thread jack beany
Hi All,

Trying to do a
PropertyUtils.copyProperties(DynaValidatorForm,mybean)
to copy the current values of my bean into my DynaValidatorForm and I hit a 
java.lang.NullPointerException when it tries to do this.

Problem seems to be when I check for the form parameter (ActionForm -> 
Execute), and try to create one if it doesnt exist:
form = new DynaValidatorForm();
this fails to instanciate a new instance, leaving form==null.

How *should* I be passing values to DynaValidatorForm?!

Thanks
J
_
Get Hotmail on your mobile phone http://www.msn.co.uk/msnmobile
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Returning values from a BasicDynaBean in jsp

2003-08-14 Thread jack beany
Short and simple this time,

What's best practice on displaying (in either jstl or struts) values from 
within a BasicDynaBean?

Ideally want a working version of 

RowSetDynaClass is one of the best things in struts but has to be one of the 
worst documented.

Thanks!

_
Find a cheaper internet access deal - choose one to suit you. 
http://www.msn.co.uk/internetaccess

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


Re: Returning values from a BasicDynaBean in jsp

2003-08-07 Thread jack beany
From: Kris Schneider <[EMAIL PROTECTED]>
Didn't like the JSTL Result suggestion, I guess ;-). As a JavaBean,
Well personally I have no preference, just want something that works 
efficiently and cleanly :)
The example you have had the query in the jsp, wheras I'm trying to stay 
away from anything like that, and keep it MVC2 as possible!  Using the 
lovely new RowSetDynaClass I've been trying to do something that really 
should be very simple, but I guess it's just not a very mature technology 
yet :-/

BasicDynaBean only exposes two properties: "dynaClass" and "class" (both 
are
read-only). So, that's all JSTL can get out of a BasicDynaBean instance. 
The
Struts tags, on the other hand, leverage BeanUtils/PropertyUtils so they're
perfectly capable of dealing with DynaBean properties. This is the Struts
equivalent to your JSTL snippet, but it'll actually work if "person" is a 
DynaBean:


Well that worked just lovely.  It's not going to be incredibly efficient 
when I want to return 10 columns per row I'm sure, but nevermind!  Perhaps 
in 1.2 (due sometime in 2006 ;) we'll get a map property to query.

Thanks Kris!

J

_
Get Hotmail on your mobile phone http://www.msn.co.uk/msnmobile
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Returning values from a BasicDynaBean in jsp

2003-08-07 Thread jack beany



From: Kris Schneider <[EMAIL PROTECTED]>
I guess my previous example wasn't clearly formatted, but it certainly 
wasn't
supposed to illustrate executing a query from a JSP. Here's a modified 
example:

Java (e.g. an action):
--
import javax.servlet.jsp.jstl.sql.Result;
import javax.servlet.jsp.jstl.sql.ResultSupport;
...
ResultSet rs = ...;
Result result = ResultSupport.toResult(rs);
request.setAttribute("result", result);
...
JSP:


  


  

works a treat 8-)  Gone from no working versions, to two working versions in 
a day, thanks ;)  I like the jstl version, as has already been said, it'll 
become the standard, and I'm sure it's faster just by the operations 
performed.

Now... to get the last remaining sticking point...  
page->login->return_to_page_dynamically  Have a little feedback on that, 
need to play a bit more now :)

Mucho Gracias!
J.
_
Tired of 56k? Get a FREE BT Broadband connection 
http://www.msn.co.uk/specials/btbroadband

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