You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marcus Biel <Ma...@bmw.de> on 2002/10/09 15:06:21 UTC

Struts project

Hi there,

I am studying computer science at the University in Landshut, Germany.
As part of my studies now I have to work
in a company for 5 Months. So I am working @ BMW in Munich, and they
told me to get into struts,
to realize a project with Struts.

I just started working with Struts. I've read all tutorials I could find
on the Jakarta site,
but so far I couldn't get the answers I need, as the tutorials never go
into detail,
they're just scratching the topic imho.

What I am trying to develope a page that connects to a database.

You should have the ability to select which data to be shown, to be able
to edit and delete every data record,
and to be able to add new data records.
I did my very best, but I am just to new to struts to solve this.

So it would help if you would have examples, further tutorials,
or maybe you are even so nice to have a look on the code I wrote so far 
(I know it's done wrong, but I guess it's possible to understand what I
am trying to do)

First of all, I am trying to dynamically build a select box, filled with
all bmw factories.
(Called "Werke" in german)
Then, the user can choose, if he want to see the data of all factories
or just of a special factory.
If he selected Something and pushes submit, a table with the data
records should be displayed.
The First row should give the ability to order the records by the
selected data record -
one click ascending, two clicks descending.

Then there should be a field to add a new data record, which you can
leave blank if you don't want to add new data.
Then there's a loop that shows all selected data by the selected order,
and each data record can be edited or deleted.

Kinda complicated! :-)

Thanks for your help!

by,
Marcus

Here comes my code of the jsp:

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ page import="Book"%>

<html:html locale="true">
	<head>
		<html:base/>
		<title><bean:message key="searchGroup.title"/></title>
	</head>
	<body bgcolor="white">
		<h2>Search Group</h2>
		<%
			Vector werkList = request.getAttribute("werkList");
			ArrayList beanCollection = request.getAttribute("beanCollection");
		%>
		Werk<br>
		<html:form action="showData.do">
			<html:select property="werke" size="1">
				<logic:iterate id="werke" collection="<%=werkList%>" >
					<html:option value="<bean:write name="werke" property="werkList"
/>" >
					</html:option>
				</logic:iterate>
			</html:select>
			<html:submit property="Datensätze ausgeben" value="show"/>
			<logic:present name="show">
				<font color="#666666"> AEM_GRUPPE </font><br>
				<font face="Arial, Helvetica" size=2>
				<table border="0" cellpadding="0" cellspacing="1">
				<tr bgcolor="#000090">
				<td align="center">
				<table border="0" cellpadding="3" cellspacing="1" width="100%">
				<tr bgcolor="#b0ffc0">
				<td><html:link
page="/showData.do?werk=show&sort=GID&order=flag">GID</html:link></td>
				<td><html:link
page="/showData.do?werk=show;sort=BESCHREIBUNG;order=flag">BESCHREIBUNG</html:link></td>
				<td><html:link
page="/showData.do?werk=show;sort=STIWO;order=flag">STIWO</html:link></td>
				<td><html:link
page="/showData.do?werk=show;sort=MO;order=flag">MO</html:link></td>
				<td><html:link
page="/showData.do?werk=show;sort=STIWOERG;order=flag">STIWOERG</html:link></td>
				<td><html:link
page="/showData.do?werk=show;sort=ORG1;order=flag">ORG1</html:link></td>
				<td><html:link
page="/showData.do?werk=show;sort=ORG2;order=flag">ORG2</html:link></td>
				<td><html:link
page="/showData.do?werk=show;sort=GID;order=flag">GID</html:link></td>
				<td>Editieren</td>
				<td>Löschen</td>
               			</tr>

				<tr>
					<td> <html:text property="bean.gid" /> </td>
					<td> <html:text property="bean.beschreibung" /> </td>
					<td> <html:text property="bean.stiwo" /> </td>
					<td> <html:text property="bean.mo" /> </td>
					<td> <html:text property="bean.stiwoerg" /> </td>
					<td> <html:text property="bean.org1" /> </td>
					<td> <html:text property="bean.org2" /> </td>
					<td> <html:link
page="/showData.do?save=bean.gid">speichern</html:link></td>
					<td> <html:link
page="/showData.do?reset=bean.gid">zurücksetzen</html:link></td>
				</tr>

				<logic:iterate id="werke" collection="<%=beanCollection%>" >
				<tr>
					<td> <bean:write name="beanCollection" property="bean.gid" /> </td>
					<td> <bean:write name="beanCollection" property="bean.beschreibung"
/> </td>
					<td> <bean:write name="beanCollection" property="bean.stiwo" />
</td>
					<td> <bean:write name="beanCollection" property="bean.mo" /> </td>
					<td> <bean:write name="beanCollection" property="bean.stiwoerg" />
</td>
					<td> <bean:write name="beanCollection" property="bean.org1" />
</td>
					<td> <bean:write name="beanCollection" property="bean.org2" />
</td>
					<td> <html:link
page="/showData.do?edit=bean.gid">edit</html:link></td>
					<td> <html:link
page="/showData.do?del=bean.gid">delete</html:link></td>
				</tr>
				</logic:iterate>
		</logic:present>
		</html:form>
	</body>
</html:html>

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


RE: Struts project

Posted by Andrew Hill <an...@gridnode.com>.
If you havent already, download and read the review copies of Chuck's struts
book on theserverside.
http://www2.theserverside.com/resources/strutsreview.jsp
A great resource for learning struts!

So have they let you test drive the M5 yet? ;-)

-----Original Message-----
From: Marcus Biel [mailto:Marcus.Biel@bmw.de]
Sent: Wednesday, October 09, 2002 21:06
To: struts-user@jakarta.apache.org
Subject: Struts project


Hi there,

I am studying computer science at the University in Landshut, Germany.
As part of my studies now I have to work
in a company for 5 Months. So I am working @ BMW in Munich, and they
told me to get into struts,
to realize a project with Struts.

I just started working with Struts. I've read all tutorials I could find
on the Jakarta site,
but so far I couldn't get the answers I need, as the tutorials never go
into detail,
they're just scratching the topic imho.

What I am trying to develope a page that connects to a database.

You should have the ability to select which data to be shown, to be able
to edit and delete every data record,
and to be able to add new data records.
I did my very best, but I am just to new to struts to solve this.

So it would help if you would have examples, further tutorials,
or maybe you are even so nice to have a look on the code I wrote so far
(I know it's done wrong, but I guess it's possible to understand what I
am trying to do)

First of all, I am trying to dynamically build a select box, filled with
all bmw factories.
(Called "Werke" in german)
Then, the user can choose, if he want to see the data of all factories
or just of a special factory.
If he selected Something and pushes submit, a table with the data
records should be displayed.
The First row should give the ability to order the records by the
selected data record -
one click ascending, two clicks descending.

Then there should be a field to add a new data record, which you can
leave blank if you don't want to add new data.
Then there's a loop that shows all selected data by the selected order,
and each data record can be edited or deleted.

Kinda complicated! :-)

Thanks for your help!

by,
Marcus

Here comes my code of the jsp:

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ page import="Book"%>

<html:html locale="true">
	<head>
		<html:base/>
		<title><bean:message key="searchGroup.title"/></title>
	</head>
	<body bgcolor="white">
		<h2>Search Group</h2>
		<%
			Vector werkList = request.getAttribute("werkList");
			ArrayList beanCollection = request.getAttribute("beanCollection");
		%>
		Werk<br>
		<html:form action="showData.do">
			<html:select property="werke" size="1">
				<logic:iterate id="werke" collection="<%=werkList%>" >
					<html:option value="<bean:write name="werke" property="werkList"
/>" >
					</html:option>
				</logic:iterate>
			</html:select>
			<html:submit property="Datensätze ausgeben" value="show"/>
			<logic:present name="show">
				<font color="#666666"> AEM_GRUPPE </font><br>
				<font face="Arial, Helvetica" size=2>
				<table border="0" cellpadding="0" cellspacing="1">
				<tr bgcolor="#000090">
				<td align="center">
				<table border="0" cellpadding="3" cellspacing="1" width="100%">
				<tr bgcolor="#b0ffc0">
				<td><html:link
page="/showData.do?werk=show&sort=GID&order=flag">GID</html:link></td>
				<td><html:link
page="/showData.do?werk=show;sort=BESCHREIBUNG;order=flag">BESCHREIBUNG</htm
l:link></td>
				<td><html:link
page="/showData.do?werk=show;sort=STIWO;order=flag">STIWO</html:link></td>
				<td><html:link
page="/showData.do?werk=show;sort=MO;order=flag">MO</html:link></td>
				<td><html:link
page="/showData.do?werk=show;sort=STIWOERG;order=flag">STIWOERG</html:link><
/td>
				<td><html:link
page="/showData.do?werk=show;sort=ORG1;order=flag">ORG1</html:link></td>
				<td><html:link
page="/showData.do?werk=show;sort=ORG2;order=flag">ORG2</html:link></td>
				<td><html:link
page="/showData.do?werk=show;sort=GID;order=flag">GID</html:link></td>
				<td>Editieren</td>
				<td>Löschen</td>
               			</tr>

				<tr>
					<td> <html:text property="bean.gid" /> </td>
					<td> <html:text property="bean.beschreibung" /> </td>
					<td> <html:text property="bean.stiwo" /> </td>
					<td> <html:text property="bean.mo" /> </td>
					<td> <html:text property="bean.stiwoerg" /> </td>
					<td> <html:text property="bean.org1" /> </td>
					<td> <html:text property="bean.org2" /> </td>
					<td> <html:link
page="/showData.do?save=bean.gid">speichern</html:link></td>
					<td> <html:link
page="/showData.do?reset=bean.gid">zurücksetzen</html:link></td>
				</tr>

				<logic:iterate id="werke" collection="<%=beanCollection%>" >
				<tr>
					<td> <bean:write name="beanCollection" property="bean.gid" /> </td>
					<td> <bean:write name="beanCollection" property="bean.beschreibung"
/> </td>
					<td> <bean:write name="beanCollection" property="bean.stiwo" />
</td>
					<td> <bean:write name="beanCollection" property="bean.mo" /> </td>
					<td> <bean:write name="beanCollection" property="bean.stiwoerg" />
</td>
					<td> <bean:write name="beanCollection" property="bean.org1" />
</td>
					<td> <bean:write name="beanCollection" property="bean.org2" />
</td>
					<td> <html:link
page="/showData.do?edit=bean.gid">edit</html:link></td>
					<td> <html:link
page="/showData.do?del=bean.gid">delete</html:link></td>
				</tr>
				</logic:iterate>
		</logic:present>
		</html:form>
	</body>
</html:html>

--
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>