You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by th...@webmd.net on 2002/02/06 22:36:24 UTC

Hi folks, a newbie asking a question about database access from within struts applications

Hi Folks:

I am a newbie to struts so please excuse my ignorance.    Can I ask advice
or get comments from the struts gurus on this list?

What is the best way to do a client/server application from within struts?
Do you have your JDBC calls primarily on the server side in your Model
(Business) objects and then "serve" the data up to your JSP pages?

Is JDBC from within the model beans the best way with which to perform
database calls from within a struts application?    Or is there some other
kind of tool/package that is preferred (ie, similar to what entity beans do
for EJB)?

Do you try and avoid (at all costs) situations where you're keeping
resultsets open between requests and such?     is there a web-site that
discusses the best way to do database applications from within the Struts
framework?

We'd like to duplicate our JFC/Swing application by which we log in and
create a user-profile object to be shared amongst all of our pages.   I'm
thinking with struts our user-profile object could be a JavaBean with
session-scope that can be accessed amongst all pages.   But would this bean
and other objects associated be able to use JDBC as a "clean" approach to
doing database applications with struts?

We looked at dbtaglib but don't want to use that as we want our SQL's and
business logic to be contained within beans rather than on the JSP pages.
We will consider using dbtaglib for simple things like reports and other
queries that we can throw together for users.

thanks again for any help or comments,
Theron Kousek


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to go about??

Posted by Sanjay Choudhary <ja...@yahoo.com>.
thanks ted,

Where can I get info. on tiles?

Sanjay
--- Ted Husted <hu...@apache.org> wrote:
> What Steve said, and 
> 
> Sanjay Choudhary wrote:
> > 2. Except for a HTML designer, most of the
> programmers
> > are involved with backend programming. They have
> done
> > very little HTML work. I was wondering if we will
> be
> > able to create JSP's using Struts HTML tags and
> other
> > tag libraries if a form is defined using pure
> HTML.
> 
> If the Java Engineers will also be doing alot of the
> HTML coding, I'd
> recommend looking at Tiles early in the project.
> This lets you treat
> blocks of markup (both template and dynamic) like
> methods in a program.
> This can severely reduce the amount of markup the
> engineers actually
> have to touch. Instead they incorporate it by
> reference, much like
> calling a block of methods. 
> 
> So, with tiles an engineer might create a new Result
> page by adding this
> to a configuration file 
> 
>   <definition name=".item.Result" extends=".Result">
>       <put name="title"      value="New Item Result"
> />
>       <put name="content"   
> value="/pages/item/NewResult.jsp" />
>   </definition>
> 
> and then just writing the NewResult.jsp segment that
> exposes the result
> set 
> 
> (simplified from production, but this would work) 
> 
> <logic:notEqual name="RESULT" property="size"
> value="0"> 
> <TR><TD><TABLE width="100%">
> <TR class="greybg">
> <TH>item</TH>
> <TH>name</TH>
> <TH>category</TH>
> <TH>donor</TH>
> <TH>script</TH>
> <TH>type</TH>
> </TR>
> <TR>
> <TD><bean:write name="row" property="item"/></TD>
> <TD><bean:write name="row" property="name"/></TD>
> <TD><bean:write name="row"
> property="category"/></TD>
> <TD align="right"><bean:write name="row"
> property="donor"/></TD>
> <TD><bean:write name="row" property="script"/></TD>
> <TD><bean:write name="row"
> property="itemType"/></TD>
> </TR>
> </logic:iterate>
> </TABLE></TD><TR>
> </logic:notEqual>
> 
> The rest of the page, headers, footers, menus, even
> control buttons, can
> all be inherited from a layout that the HTML dude
> has crafted. 
> 
> Though, at the top, even that looks like a method:
> 
> <html:html>
> <tiles:useAttribute name="title" scope="request"/>
> <tiles:get name="base"/>
> <tiles:get name="header"/>
> <tiles:get name="heading"/>
> <tiles:get name="messages" />
> <TR><TD width="100%">
> <tiles:get name="caption"/>
> </TD></TR>
> <tiles:get name="content"/> <-- THIS IS THE PART THE
> ENGINEER WRITES
> <tiles:get name="back"/>
> <tiles:get name="footer"/>
> </html:html>
> 
> Of course, my production version also includes
> stylesheets so the HTML
> designer can control that too, and some internal
> links so users can
> drill down, but you get the idea. 
> 
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Java Web Development with Struts.
> -- Tel +1 585 737-3463.
> -- Web http://www.husted.com/struts/
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to go about??

Posted by Ted Husted <hu...@apache.org>.
What Steve said, and 

Sanjay Choudhary wrote:
> 2. Except for a HTML designer, most of the programmers
> are involved with backend programming. They have done
> very little HTML work. I was wondering if we will be
> able to create JSP's using Struts HTML tags and other
> tag libraries if a form is defined using pure HTML.

If the Java Engineers will also be doing alot of the HTML coding, I'd
recommend looking at Tiles early in the project. This lets you treat
blocks of markup (both template and dynamic) like methods in a program.
This can severely reduce the amount of markup the engineers actually
have to touch. Instead they incorporate it by reference, much like
calling a block of methods. 

So, with tiles an engineer might create a new Result page by adding this
to a configuration file 

  <definition name=".item.Result" extends=".Result">
      <put name="title"      value="New Item Result" />
      <put name="content"    value="/pages/item/NewResult.jsp" />
  </definition>

and then just writing the NewResult.jsp segment that exposes the result
set 

(simplified from production, but this would work) 

<logic:notEqual name="RESULT" property="size" value="0"> 
<TR><TD><TABLE width="100%">
<TR class="greybg">
<TH>item</TH>
<TH>name</TH>
<TH>category</TH>
<TH>donor</TH>
<TH>script</TH>
<TH>type</TH>
</TR>
<TR>
<TD><bean:write name="row" property="item"/></TD>
<TD><bean:write name="row" property="name"/></TD>
<TD><bean:write name="row" property="category"/></TD>
<TD align="right"><bean:write name="row" property="donor"/></TD>
<TD><bean:write name="row" property="script"/></TD>
<TD><bean:write name="row" property="itemType"/></TD>
</TR>
</logic:iterate>
</TABLE></TD><TR>
</logic:notEqual>

The rest of the page, headers, footers, menus, even control buttons, can
all be inherited from a layout that the HTML dude has crafted. 

Though, at the top, even that looks like a method:

<html:html>
<tiles:useAttribute name="title" scope="request"/>
<tiles:get name="base"/>
<tiles:get name="header"/>
<tiles:get name="heading"/>
<tiles:get name="messages" />
<TR><TD width="100%">
<tiles:get name="caption"/>
</TD></TR>
<tiles:get name="content"/> <-- THIS IS THE PART THE ENGINEER WRITES
<tiles:get name="back"/>
<tiles:get name="footer"/>
</html:html>

Of course, my production version also includes stylesheets so the HTML
designer can control that too, and some internal links so users can
drill down, but you get the idea. 

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Java Web Development with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: How to go about??

Posted by John Menke <jo...@eagleinfosystems.com>.
There is a book: Struts Fast Track (See Resources Section on Jakarta Site).
It has helped me.  Also, read the API javadocs and the User Guide.

>-----Original Message-----
>From: Arnab Sengupta [mailto:arnab_hunk@yahoo.com]
>Sent: Thursday, February 07, 2002 12:50 AM
>To: Struts Users Mailing List
>Subject: Re: How to go about??
>
>
>Dear Sanjay,
>One and only one solution...
>Follow the structs Documentations and try to understand the struts example
>(only one is there) given alogn with the struts 1.0. It's too good and if
>one understands the inner logic of the example,he/she is unstoppable.
>It might take a week's time ..but worth investing.
>Best of luck and welcome to struts..
>Arnab.
>----- Original Message -----
>From: "Sanjay Choudhary" <ja...@yahoo.com>
>To: "Struts Users Mailing List" <st...@jakarta.apache.org>
>Sent: Thursday, February 07, 2002 3:41 AM
>Subject: How to go about??
>
>
>> Hi Friends,
>>
>> I am very new to Struts. All I have done is worked out
>> couple of examples from web to understand the
>> Architecture. We are in a process of designing a
>> Product and plan to use Struts Framework with EJB's.
>>
>> In my team
>> 1. No one has any knowledge about Struts but they are
>> very good with Java and J2EE.
>>
>> 2. Except for a HTML designer, most of the programmers
>> are involved with backend programming. They have done
>> very little HTML work. I was wondering if we will be
>> able to create JSP's using Struts HTML tags and other
>> tag libraries if a form is defined using pure HTML.
>>
>> 3. What is the best way to go about to learn Struts to
>> use in practical life and how much time it takes?
>>
>> 4. What strategies did you guys adopt to move to
>> Struts?
>>
>> 5. All pointers to valuable resources and design
>> stratergies will be appreciated.
>>
>> Thanks you ,
>> Sanjay
>>
>>
>>
>>
>>
>>
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Send FREE Valentine eCards with Yahoo! Greetings!
>> http://greetings.yahoo.com
>>
>> --
>> To unsubscribe, e-mail:
><ma...@jakarta.apache.org>
>> For additional commands, e-mail:
><ma...@jakarta.apache.org>
>
>
>_________________________________________________________
>Do You Yahoo!?
>Get your free @yahoo.com address at http://mail.yahoo.com
>
>
>--
>To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to go about??

Posted by Arnab Sengupta <ar...@yahoo.com>.
Dear Sanjay,
One and only one solution...
Follow the structs Documentations and try to understand the struts example
(only one is there) given alogn with the struts 1.0. It's too good and if
one understands the inner logic of the example,he/she is unstoppable.
It might take a week's time ..but worth investing.
Best of luck and welcome to struts..
Arnab.
----- Original Message -----
From: "Sanjay Choudhary" <ja...@yahoo.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, February 07, 2002 3:41 AM
Subject: How to go about??


> Hi Friends,
>
> I am very new to Struts. All I have done is worked out
> couple of examples from web to understand the
> Architecture. We are in a process of designing a
> Product and plan to use Struts Framework with EJB's.
>
> In my team
> 1. No one has any knowledge about Struts but they are
> very good with Java and J2EE.
>
> 2. Except for a HTML designer, most of the programmers
> are involved with backend programming. They have done
> very little HTML work. I was wondering if we will be
> able to create JSP's using Struts HTML tags and other
> tag libraries if a form is defined using pure HTML.
>
> 3. What is the best way to go about to learn Struts to
> use in practical life and how much time it takes?
>
> 4. What strategies did you guys adopt to move to
> Struts?
>
> 5. All pointers to valuable resources and design
> stratergies will be appreciated.
>
> Thanks you ,
> Sanjay
>
>
>
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Send FREE Valentine eCards with Yahoo! Greetings!
> http://greetings.yahoo.com
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


How to go about??

Posted by Sanjay Choudhary <ja...@yahoo.com>.
Hi Friends,

I am very new to Struts. All I have done is worked out
couple of examples from web to understand the
Architecture. We are in a process of designing a
Product and plan to use Struts Framework with EJB's.

In my team
1. No one has any knowledge about Struts but they are
very good with Java and J2EE.

2. Except for a HTML designer, most of the programmers
are involved with backend programming. They have done
very little HTML work. I was wondering if we will be
able to create JSP's using Struts HTML tags and other
tag libraries if a form is defined using pure HTML.

3. What is the best way to go about to learn Struts to
use in practical life and how much time it takes?

4. What strategies did you guys adopt to move to
Struts? 

5. All pointers to valuable resources and design
stratergies will be appreciated.

Thanks you ,
Sanjay 







__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>