struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mallik <malli...@yahoo.com>
Subject <bean:define> help?
Date Sat, 18 Nov 2006 07:37:06 GMT

Hi friends
this is my situation:
here i am going do app for a college, there may be any no of colleges and
each college may have any no of blocks.
i have a jsp where i display all the details of blocks in row wise(this is a
view block details page) and there will be some provision to modify any row(
means that block details).
>From there i transfer to blocksModify page in which she can modify any
details.
Problem is:
My modify blocks form has some text boxes and some select bokes 
i am getting the text box values,but for the select box the all ready
assiged college name should display from the rest of the options . i am not
getting this

i am using the same form bean for both listing college details in select box
and displaying the rest of the details

this is my modify antion class
-----------------------------------------------------------------------------------
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception
	{
		String id = request.getParameter("id");
		if(id==null)
			return mapping.findForward("accessDenied");
		String query = null;
		BlocksForm block = null;		
		try
		{
			ds = getDataSource(request);
			conn = ds.getConnection();
			stmt = conn.createStatement();
		}catch(SQLException e)
		{
			e.printStackTrace();
			return mapping.findForward("sqlException");
		}
		
		try
		{
			query = "SELECT COLLEGEID,SHORTDESCRIPTION FROM COLLEGES";
			rs = stmt.executeQuery(query);
			colleges = new ArrayList();
			if(rs.next())
			{
				do
				{			
					block =  new BlocksForm();
					block.setCollege(rs.getString("COLLEGEID"));
					block.setCollegeShortDesc(rs.getString("SHORTDESCRIPTION"));
					colleges.add(block);
				}while(rs.next());
			}
			request.getSession().setAttribute("COLLEGES",colleges);
			query = "SELECT UNIQUE BLOCKID, SHORTDESCRIPTION, DESCRIPTION, ADDRESS,
PHONE, COLLEGEID FROM BLOCKS WHERE BLOCKID='"+id+"' ORDER BY
SHORTDESCRIPTION";
			rs = stmt.executeQuery(query);
			blocks = new ArrayList();
			
			if(rs.next())
			{
				block = new BlocksForm();
				block.setId(rs.getString("BLOCKID"));
				block.setShortDesc(rs.getString("SHORTDESCRIPTION"));
				block.setDesc(rs.getString("DESCRIPTION"));
				block.setLocation(rs.getString("ADDRESS"));
				block.setPhoneNo(rs.getString("PHONE"));
				block.setCollege(rs.getString("COLLEGEID"));
				blocks.add(block);
				
			}else
			{
				return mapping.findForward("noCollegeSetup");
			}
		}catch(Exception e)
		{
			e.printStackTrace();
			return mapping.findForward("exception");
		}finally
		{
			if(conn!=null)
				conn.close();
		}
		request.getSession().setAttribute("BLOCKS", blocks);
		return mapping.findForward("continue");
		
	}
-------------------------------------------------------------------------------------------------------------
this is my modify jsp page
-------------------------------------------------------------------------------------------------------------
<html:errors/>
																
								<table id="blocksTable"   width="600" class="tableborder1" 
cellspacing="2" >
									<tr>
										<td colspan="5" class="heading"><bean:message
key="subheading.blocksDetails"/></td>
									</tr>
									<logic:iterate id="blocks" name="BLOCKS">
									<tr>
										<td class="rightsubheading1"><bean:message key="label.id"/></td>
										<td class="leftsubheading1"><html:text name="blocks" property="id"
styleClass="formtext10"/></td>
									</tr>
									
									<tr>
										<td class="rightsubheading1"><bean:message
key="label.shortDesc"/></td>
										<td class="leftsubheading1"><html:text name="blocks"
property="shortDesc" styleClass="formtext10"/></td>
									</tr>
									<tr>
										<td class="rightsubheading1"><bean:message key="label.desc"/></td>
										<td class="leftsubheading1">
											<html:textarea property="desc"  name="blocks" cols="62"
rows="4"></html:textarea>
										</td>
									</tr>
									
									<tr>
										<td class="rightsubheading1"><bean:message
key="label.location"/></td>
										<td class="leftsubheading1"><html:text  name="blocks"
property="location" styleClass="formtext15"/></td>
									</tr>
									<tr>
										<td class="rightsubheading1"><bean:message
key="label.phoneNo"/></td>
										<td class="leftsubheading1"><html:text  name="blocks"
property="phoneNo" styleClass="formtext15"/></td>
									</tr>
									<tr>
										<td class="rightsubheading1"><bean:message
key="label.college"/></td>
										<td class="leftsubheading1">
											<bean:define id="colleges" name="COLLEGES" scope="session" />
											<html:select property="college" styleClass="formlist1">
												<html:option value="">Select</html:option>
												<html:options collection="colleges" property="college"
labelProperty="collegeShortDesc"/>
											</html:select>	
										</td>
									</tr>
									</logic:iterate>
									<tr>
										<td  class="centersubheading1"><html:button property="cancel"
value="Cancel" onclick="javaScript:history.go(-1);"/></td>
										<td  class="centersubheading1"><html:submit property="update"
value="Update"/></td>
									</tr>
								</table>
-----------------------------------------------------------------------------------------------------------------------------------
let me know where i did worng or how to handle this
help me please

ur's
Mallik

-- 
View this message in context: http://www.nabble.com/%3Cbean%3Adefine%3E-help--tf2658641.html#a7415847
Sent from the Struts - User mailing list archive at Nabble.com.


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


Mime
View raw message