Checkbox values
Hello all, I'm trying to show the selected rows in a html table by using check boxes. I'm using the same jsp to show the selected row indexes of the table. What am I'm doing wrong because I'm not able to see the selected indexes: logic:present name=selectedBook logic:iterate id=sel name=selectedBook brselected index = bean:write name=sel/ /logic:iterate /logic:present logic:iterate id=book name=BookListKey scope=request tr tdhtml:checkbox property=selectedBookbean:write name=book property=id//html:checkbox/td tdbean:write name=book property=authorLastName/nbsp;/td tdbean:write name=book property=authorFirstName/nbsp;/td tdbean:write name=book property=title/nbsp;/td /tr /logic:iterate tia, met vriendelijke groeten, salutations sincères, kind regards, Geert Van Landeghem Reynders Etiketten NV tel: +32 3 460.32.81 gsm: +32 477.75.95.33 mailto:[EMAIL PROTECTED] Give me the power to accept the things i cannot change, the strength to change the things i can change, and the insight to tell the difference - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checkbox values: how to substitute the value attribute by the book id?
Sumit, I found a solution to this problem as following: !-- presenting the selected checkbox values -- logic:present name=bookListForm property=selectedBook logic:iterate id=sel name=bookListForm property=selectedBook brindex = bean:write name=sel/ /logic:iterate /logic:present !-- the form with the checkbox for each row of the html table -- !-- refers to this page being executed again -- html:form action=/booklist table width=95% border=1 tr th bgcolor=#330066font color=#FFnbsp;/font/th th bgcolor=#330066font color=#FFAuthorL/font/th th bgcolor=#330066font color=#FFAuthorF/font/th th bgcolor=#330066font color=#FFTitle/font/th /tr logic:iterate id=book name=BookListKey scope=request tr tdhtml:checkbox property=selectedBook value=??bean:write name=book property=id//html:checkbox/td tdbean:write name=book property=authorLastName/nbsp;/td tdbean:write name=book property=authorFirstName/nbsp;/td tdbean:write name=book property=title/nbsp;/td /tr /logic:iterate /table html:submitProcess/html:submit /html:form -Original Message- From: Sumit S. [mailto:[EMAIL PROTECTED] Sent: vrijdag 14 november 2003 12:51 To: Struts Users Mailing List Subject: RE: Checkbox values Geert, this would create BookListKey[i].selectedBook = 1 for Checked Books When you have to render this info try logic:present name=BookListKey logic:iterate id=book name=BookListKey logic:equal name=book property=selectedBook value=1 brselected index = bean:write name=book property=id/ /logic:equal /logic:iterate /logic:present hope this helps Regards Sumit -Original Message- From: Geert Van Landeghem [mailto:[EMAIL PROTECTED] Sent: Friday, November 14, 2003 4:56 PM To: Struts Users Mailing List Subject: Checkbox values Hello all, I'm trying to show the selected rows in a html table by using check boxes. I'm using the same jsp to show the selected row indexes of the table. What am I'm doing wrong because I'm not able to see the selected indexes: logic:present name=selectedBook logic:iterate id=sel name=selectedBook brselected index = bean:write name=sel/ /logic:iterate /logic:present logic:iterate id=book name=BookListKey scope=request tr tdhtml:checkbox property=selectedBookbean:write name=book property=id//html:checkbox/td tdbean:write name=book property=authorLastName/nbsp;/td tdbean:write name=book property=authorFirstName/nbsp;/td tdbean:write name=book property=title/nbsp;/td /tr /logic:iterate tia, met vriendelijke groeten, salutations sincères, kind regards, Geert Van Landeghem Reynders Etiketten NV tel: +32 3 460.32.81 gsm: +32 477.75.95.33 mailto:[EMAIL PROTECTED] Give me the power to accept the things i cannot change, the strength to change the things i can change, and the insight to tell the difference - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checkbox values: how to substitute the value attribute by the book id?
But how to substitute the value=?? by the book id? Geert -Original Message- From: Geert Van Landeghem Sent: vrijdag 14 november 2003 14:48 To: Struts Users Mailing List Subject: RE: Checkbox values: how to substitute the value attribute by the book id? Sumit, I found a solution to this problem as following: !-- presenting the selected checkbox values -- logic:present name=bookListForm property=selectedBook logic:iterate id=sel name=bookListForm property=selectedBook brindex = bean:write name=sel/ /logic:iterate /logic:present !-- the form with the checkbox for each row of the html table -- !-- refers to this page being executed again -- html:form action=/booklist table width=95% border=1 tr th bgcolor=#330066font color=#FFnbsp;/font/th th bgcolor=#330066font color=#FFAuthorL/font/th th bgcolor=#330066font color=#FFAuthorF/font/th th bgcolor=#330066font color=#FFTitle/font/th /tr logic:iterate id=book name=BookListKey scope=request tr tdhtml:checkbox property=selectedBook value=??bean:write name=book property=id//html:checkbox/td tdbean:write name=book property=authorLastName/nbsp;/td tdbean:write name=book property=authorFirstName/nbsp;/td tdbean:write name=book property=title/nbsp;/td /tr /logic:iterate /table html:submitProcess/html:submit /html:form -Original Message- From: Sumit S. [mailto:[EMAIL PROTECTED] Sent: vrijdag 14 november 2003 12:51 To: Struts Users Mailing List Subject: RE: Checkbox values Geert, this would create BookListKey[i].selectedBook = 1 for Checked Books When you have to render this info try logic:present name=BookListKey logic:iterate id=book name=BookListKey logic:equal name=book property=selectedBook value=1 brselected index = bean:write name=book property=id/ /logic:equal /logic:iterate /logic:present hope this helps Regards Sumit -Original Message- From: Geert Van Landeghem [mailto:[EMAIL PROTECTED] Sent: Friday, November 14, 2003 4:56 PM To: Struts Users Mailing List Subject: Checkbox values Hello all, I'm trying to show the selected rows in a html table by using check boxes. I'm using the same jsp to show the selected row indexes of the table. What am I'm doing wrong because I'm not able to see the selected indexes: logic:present name=selectedBook logic:iterate id=sel name=selectedBook brselected index = bean:write name=sel/ /logic:iterate /logic:present logic:iterate id=book name=BookListKey scope=request tr tdhtml:checkbox property=selectedBookbean:write name=book property=id//html:checkbox/td tdbean:write name=book property=authorLastName/nbsp;/td tdbean:write name=book property=authorFirstName/nbsp;/td tdbean:write name=book property=title/nbsp;/td /tr /logic:iterate tia, met vriendelijke groeten, salutations sincères, kind regards, Geert Van Landeghem Reynders Etiketten NV tel: +32 3 460.32.81 gsm: +32 477.75.95.33 mailto:[EMAIL PROTECTED] Give me the power to accept the things i cannot change, the strength to change the things i can change, and the insight to tell the difference - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Accessing application scope in Action.execute()
The Action class contains the protected ActionServlet servlet variable through which each subclass can access the servlet context. A good approach to accessing session and application objects is by extending the Action class (I've got this from O'Reilly's Programming Jakarta Struts) By extending this class all your action classes inherit these common methods (getSessionObject, getApplicationObject, ...) abstract public class EnterpriseBaseAction extends Action { /** * Retrieve a session object based on the request and the attribute name. */ protected Object getSessionObject(HttpServletRequest req, String attrName) { Object sessionObj = null; HttpSession session = req.getSession(false); if ( session != null ){ sessionObj = session.getAttribute(attrName); } return sessionObj; } /** * Retrieve an object from the application scope by its name. This is * a convience method. */ protected Object getApplicationObject(String attrName) { return servlet.getServletContext().getAttribute(attrName); } public boolean isLoggedIn( HttpServletRequest request ){ UserContainer container = getUserContainer(request); if ( container.getUserView() != null ){ return true; }else{ return false; } } /** * Return the instance of the ApplicationContainer object. */ protected ApplicationContainer getApplicationContainer() { return (ApplicationContainer)getApplicationObject(IConstants.APPLICATION_CONTAINER_KEY); } /** * Retrieve the UserContainer for the user tier to the request. */ protected UserContainer getUserContainer(HttpServletRequest request) { UserContainer userContainer = (UserContainer)getSessionObject(request, IConstants.USER_CONTAINER_KEY); // Create a UserContainer for the user if it doesn't exist already if(userContainer == null) { userContainer = new UserContainer(); userContainer.setLocale(request.getLocale()); HttpSession session = request.getSession(true); session.setAttribute(IConstants.USER_CONTAINER_KEY, userContainer); } return userContainer; } } -Original Message- From: Looser [mailto:[EMAIL PROTECTED] Sent: maandag 10 november 2003 16:03 To: struts Mailinglist Subject: Accessing application scope in Action.execute() Hi, is there any chance to access objects in application scope in my action classes ? I have to override the .execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) method but none of these parameters give me access to application scope like 'getServletContext().getAttribute(myAttribute)' would do. Which is the best practise to store objects in application scope and retrieve them back in my ActionClasses ? Thx for your answers... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: data-source connection keeps closing
David, hope this helps: data-sources data-source type=com.mysql.jdbc.jdbc2.optional.MysqlDataSource set-property property=autoCommit value=true/ set-property property=description value=MySql Data Source/ set-property property=driverClass value=com.mysql.jdbc.Driver/ set-property property=maxCount value=10/ set-property property=minCount value=2/ set-property property=user value=dbuser/ set-property property=password value=x/ set-property property=url value=jdbc:mysql://localhost/collection/ /data-source /data-sources I'm using the latest stable mysql driver mysql-connector-java-3.0.9-stable-bin.jar. This is not the best example since it accesses the db from within a jsp: Connection conn = null; DataSource dataSource = null; try { dataSource = (DataSource) getServletContext().getAttribute(Action.DATA_SOURCE_KEY); conn = dataSource.getConnection(); Statement s = conn.createStatement(); ResultSet rs = s.executeQuery( select count(*) from collection.web_users); if (rs.next()) { % Number of users defined=%=rs.getInt(1) % % } } catch (SQLException sqle) { log(Connection.process, sqle); } finally { //enclose this in a finally block to make //sure the connection is closed try { if (conn != null) conn.close(); } catch (SQLException e) { log(Connection.close, e); } } % met vriendelijke groeten, salutations sincères, kind regards, Geert Van Landeghem Reynders Etiketten NV tel: +32 3 460.32.81 gsm: +32 477.75.95.33 mailto:[EMAIL PROTECTED] Give me the power to accept the things i cannot change, the strength to change the things i can change, and the insight to tell the difference -Original Message- From: David Parry [mailto:[EMAIL PROTECTED] Sent: donderdag 6 november 2003 14:41 To: [EMAIL PROTECTED] Subject: data-source connection keeps closing After days of googling and trawling through the mail archives, I still can't find any explanation for this... I'm trying to get a DataSource that's been configured in struts-config.xml and use the connection in my Model. Every time I try to use the connection it says that it has closed (before even getting the chance to create a statement!). The connection that is returned sure enough has the correct URL, user, password driver, and independent tests have confirmed that mysql is running, that permissions are acceptable for that user, it's accessible from Java, blah blah... I've looked through most of the examples listed on the struts resources pages, but I can't seem to find anything that has a simple direct-to-jdbc example. Currently I'm not in a position to be using anything like Hibernate, etc, so all those examples are kinda not helpful in my situation. QUESTION: Does anyone have a simple canonical example of connecting to a JDBC database (preferably MySQL) via struts? I'm using Tomcat 4.1, MySQL 4.1.0, MySQL Connector 3.0.9 and struts 1.2. Error is as follows: 14:21:44,750 DEBUG QueryAction:55 - dataSource = [EMAIL PROTECTED] 14:21:45,561 DEBUG QueryAction:59 - myConnection = [EMAIL PROTECTED] 14:21:45,636 DEBUG QueryAction:61 - queryModel = [EMAIL PROTECTED] 14:21:45,677 DEBUG Model:109 - findNodes(null) 14:21:45,682 DEBUG Model:384 - readAll(node) 14:21:45,687 DEBUG Model:385 - connection = [EMAIL PROTECTED] 14:21:45,712 ERROR Model:392 - SQL Exception java.sql.SQLException: Connection is closed. at org.apache.commons.dbcp.DelegatingConnection.checkOpen(DelegatingConnect ion.java:245) at org.apache.commons.dbcp.DelegatingConnection.createStatement(DelegatingC onnection.java:170) at com.imc.semantic.Model.readAll(Model.java:389) struts-config.xml: data-sources data-source type=org.apache.commons.dbcp.BasicDataSource set-property property=driverClassName value=org.gjt.mm.mysql.Driver/ set-property property=url value=jdbc:mysql://localhost/semantic/ set-property property=username value=root/ set-property property=password value=/ set-property property=maxActive value=10 / set-property property=maxWait value=5000 / set-property property=defaultAutoCommit value=false / set-property property=defaultReadOnly value=false / set-property property=validationQuery value=SELECT COUNT(*) FROM node / /data-source /data-sources and the Java code in the Action: public ActionForward execute(ActionMapping mapping
Newbie question: how to reload the struts config file without rebooting tomcat?
Hello all, how do I reload changes to the struts config file without rebooting tomcat? kind regards, Geert -Original Message- From: Frers Michael [mailto:[EMAIL PROTECTED] Sent: woensdag 29 oktober 2003 9:49 To: Struts Users Mailing List Subject: Re: a query regarding message-resources Hello on my first look: shouldnt u use message-resources property=languages / i think there is a missing s - Original Message - From: Mahin Jeyachandran [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Wednesday, October 29, 2003 4:57 AM Subject: a query regarding message-resources good day all, I'm new to struts frame work... I'm using a property file names languages.properties instead of ApplicationResources.properties Also I have an entry in my struts-config.xml like the following... message-resources property=language / I also placed the property file in WEB-INF/classes/ but it seems that the property file languages.properties is not detected. shld I make any changes or any entry in the web.xml to make my new property file visible I'm using web-logic6.1. pls help.. Regards, Mahin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]