ActionMessages with redirect
Hi all, Just before creating an ActioForward in my Action class, i am storing some messages using SaveErrors(). And I am using ActionForward(String path, boolean redirect) for creating the ActionForward with 'true' value for redirect parameter. My question is by doing this can I display the ActionMessages that I have saved using SaveErrors()? If not then how can I save ActionMessages/ActionErrors so that they are visible to me even after making a redirect? any suggestions? --RahulJoshi
How to remove the unwanted ???en_US string from ActionMessages
Hello all, I am facing a wierd problem in my application. I want to add an ActionMessage in the ACTION (LoginAction) class and then display the message in the JSP page. In the JSP page, the messages are found without a problem (so my ApplicationResources.properties configuration is fine), however while prinintg them, the string ???en_US and ??? gets attached to my message before and after respectively. ???en_US.my-message??? How do I get rid of these strings??? I searched the discussion-list for similar problems/solutions and found this thread: http://www.mail-archive.com/user@struts.apache.org/msg27565.html However, the solution in that threads talks about using the presentation logic as follows: html:messages id=errmsgs libean:write name=errmsgs//li /html:messages But thats exactly how I am doing also. But for me it still gives the error. Below is the configuration and code snippets that I am using: In struts-config,xml message-resources parameter=myApp.ApplicationResources null=false/ In LoginAction.java if (username == null || username.trim().length() == 0){ ActionMessages messages = new ActionMessages(); ActionMessage message = new ActionMessage(Username/Password cannot be empty); messages.add(credentials.empty, message); saveMessages(request,messages); In the JSP page html:messages id=message message=true div class=success bean:write name=message/br /divbr/ /html:messages The output I get is ???en_US.Username/Password cannot be empty??? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to remove the unwanted ???en_US string from ActionMessages
Hi there, try this: if (username == null || username.trim().length() == 0){ ActionMessages messages = new ActionMessages(); ActionMessage message = new ActionMessage(credentials.empty); messages.add(ActioneMessages.GLOBAL_ERROR, message); saveMessages(request,messages); } Basically, the thing to note here that ActionMessage takes a key from the resource file which I assumed credentails.empty is. The first parameter of the ActionMessges.add(...) is the property against which error is being stored or the generic global_error constant. HTH. ATTA On 9/27/05, Kaizar Amin [EMAIL PROTECTED] wrote: Hello all, I am facing a wierd problem in my application. I want to add an ActionMessage in the ACTION (LoginAction) class and then display the message in the JSP page. In the JSP page, the messages are found without a problem (so my ApplicationResources.properties configuration is fine), however while prinintg them, the string ???en_US and ??? gets attached to my message before and after respectively. ???en_US.my-message??? How do I get rid of these strings??? I searched the discussion-list for similar problems/solutions and found this thread: http://www.mail-archive.com/user@struts.apache.org/msg27565.html However, the solution in that threads talks about using the presentation logic as follows: html:messages id=errmsgs libean:write name=errmsgs//li /html:messages But thats exactly how I am doing also. But for me it still gives the error. Below is the configuration and code snippets that I am using: In struts-config,xml message-resources parameter=myApp.ApplicationResources null=false/ In LoginAction.java if (username == null || username.trim().length() == 0){ ActionMessages messages = new ActionMessages(); ActionMessage message = new ActionMessage(Username/Password cannot be empty); messages.add(credentials.empty, message); saveMessages(request,messages); In the JSP page html:messages id=message message=true div class=success bean:write name=message/br /divbr/ /html:messages The output I get is ???en_US.Username/Password cannot be empty??? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts action servlet mapping, getPathInfo() returns null
Again, thank you very much Laurie. I couldn't understand how ** wildcard mapping could work with suffix mapping (*.do). I have tried, in web.xml, *.do/** but tomcat said invalid url-pattern. If I manage to get ** wilcard mapping work with *.do, I will be able to correctly process a request like http://localhost:8080/myapp/server.do/chapter1/1.html Also, I've tried *.do** , tomcat did accept this but this time, it expected me to write ** at the end of all URL's. That is, it didn't work as a wildcard mapping. And in struts-config.xml, I modified my action as action path=/server** ... but this didn't work either. It seems that ** wildcard mapping is not possible with *.do suffix mapping. What do you think Laurie? -- Forwarded message -- From: Laurie Harper [EMAIL PROTECTED] To: user@struts.apache.org Date: Mon, 26 Sep 2005 14:31:10 -0400 Subject: Re: user Digest 25 Sep 2005 21:39:29 - Issue 6130 emre akbas wrote: Now, I have another problem. We have written our Struts application using prefix mappings, i.e *.do. In order to use DownloadAction with ** mapping, we should migrate to suffix mapping, i.e. /do/* . Is there an easy way of migrating a whole Struts application from prefix mapping to suffix mapping? Or, is it possible that both mappings exists in web.xml ? (Sorry, if these are weird questions.) [Note: '*.do' is a suffix, /do/* is a prefix (pre- - previous); just to reduce any confusion for people following along ;-)] Actually, I think wildcard mappings *should* work with suffix mapping too, though I've never tried it. But you can define both types of mapping in web.xml, so long as you pick a prefix your application doesn't already use. In other words, as long as you don't already have linkes that start /do/... then adding a /do/* mapping is fine. Migrating your whole app from one mapping style to the other wouldn't be super hard -- just find anywhere you have an explicit .do and update appropriately. However, I wouldn't recommend trying that if this is the only driver. If what you have works, keep it ;-) L.
error using struts.
Hello i am bigning using struts. i have made one aplication, little application and i have the first error: [27/09/05 12:26:04:688 CEST] 0027 PropertyMessa I Initializing, config=' org.apache.struts.util.LocalStrings', returnNull=true [27/09/05 12:26:04:719 CEST] 0027 PropertyMessa I Initializing, config=' org.apache.struts.action.ActionResources', returnNull=true [27/09/05 12:26:04:844 CEST] 0027 ActionServlet E Parsing error processing resource path [27/09/05 12:26:04:875 CEST] 0027 ActionServlet E TRAS0014I: Se ha anotado cronológicamente la excepción siguiente java.net.MalformedURLException: SRVE0238E: Las vías de accesos de recursos tienen que empezar por una barra inclinada. at com.ibm.ws.webcontainer.webapp.WebApp.getResource(WebApp.java:1915) at com.ibm.ws.webcontainer.facade.ServletContextFacade.getResource( ServletContextFacade.java:100) at org.apache.struts.action.ActionServlet.parseModuleConfigFile( ActionServlet.java:1002) at org.apache.struts.action.ActionServlet.initModuleConfig( ActionServlet.java:955) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:470) at javax.servlet.GenericServlet.init(GenericServlet.java:256) can you help me? thanks
Re: How to remove the unwanted ???en_US string from ActionMessages
Hi Atta, As per your suggestions, I changed the code to if (username == null || username.trim().length() ==0 ){ ActionMessages messages = new ActionMessages(); ActionMessage message = new ActionMessage(Username/Password cannot be empty); messages.add(ActionMessages.GLOBAL_MESSAGE, message); saveMessages(request,messages); But even this doesnt solve my problem. The output I get is: ???en_US.Username/Password cannot be empty??? Hi there, try this: if (username == null || username.trim().length() == 0){ ActionMessages messages = new ActionMessages(); ActionMessage message = new ActionMessage(credentials.empty); messages.add(ActioneMessages.GLOBAL_ERROR, message); saveMessages(request,messages); } Basically, the thing to note here that ActionMessage takes a key from the resource file which I assumed credentails.empty is. The first parameter of the ActionMessges.add(...) is the property against which error is being stored or the generic global_error constant. HTH. ATTA On 9/27/05, Kaizar Amin [EMAIL PROTECTED] wrote: Hello all, I am facing a wierd problem in my application. I want to add an ActionMessage in the ACTION (LoginAction) class and then display the message in the JSP page. In the JSP page, the messages are found without a problem (so my ApplicationResources.properties configuration is fine), however while prinintg them, the string ???en_US and ??? gets attached to my message before and after respectively. ???en_US.my-message??? How do I get rid of these strings??? I searched the discussion-list for similar problems/solutions and found this thread: http://www.mail-archive.com/user@struts.apache.org/msg27565.html However, the solution in that threads talks about using the presentation logic as follows: html:messages id=errmsgs libean:write name=errmsgs//li /html:messages But thats exactly how I am doing also. But for me it still gives the error. Below is the configuration and code snippets that I am using: In struts-config,xml === message-resources parameter=myApp.ApplicationResources null=false/ In LoginAction.java === if (username == null || username.trim().length() == 0){ ActionMessages messages = new ActionMessages(); ActionMessage message = new ActionMessage(Username/Password cannot be empty); messages.add(credentials.empty, message); saveMessages(request,messages); In the JSP page === html:messages id=message message=true div class=success bean:write name=message/br /divbr/ /html:messages The output I get is === ???en_US.Username/Password cannot be empty??? - 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: The mailreader example, database access
Some parts of the MailReader are well designed. Others not so much. Quoting from the Struts 1.2 documentation: * http://struts.apache.org/userGuide/building_controller.html The MailReader example application included with Struts stretches [the MVC] design principle somewhat, because the business logic itself is embedded in the Action classes. This should be considered something of a bug in the design of the example, rather than an intrinsic feature of the Struts architecture, or an approach to be emulated. In order to demonstrate, in simple terms, the different ways Struts can be used, the MailReader application does not always follow best practices. A goal for Struts Classic 1.3.x is to make the MailReader a true best-practices example with multiple plugins for the data access layer. We've taken the first steps toward that here: * http://opensource2.atlassian.com/confluence/oss/display/STRUTS/MailReader To offset streamlining the MailReader, we're adding a Struts Cookbook application with coding examples outside the scope of MailReader, based on the one Steve Raeburn started here: * http://www.ninsky.com/struts/ -- HTH, Ted. http://www.husted.com/poe/ On 9/22/05, Koen Jans [EMAIL PROTECTED] wrote: The struts design guidelines states that Actions perform the processing required to deal with a request (such as saving a row into a database); this can be done by logic code embedded within the Action class itself, BUT should generally be performed by calling an appropriate method of a business logic bean. Now, in the example, the database is retrieved from the servletcontext (why is this? one instance per user?) and the Action classes itselves perform the database operations on the database directly. This seems to me like poor reuseability.. Suppose i want to create a business logic bean, let's say UserHandler, wich handles all the user savings and retrievings. So in the Action class, i create an instance of UserHandler and let the UserHandler perform all the work. If i want to do this, i should pass the database along to a method, ex. userHandler.saveUser(UserDatabase database, String userName, String email, ..) But then i have to pass the database along, losing transparacy.. Or would this not make any sense at all? thanx - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to remove the unwanted ???en_US string from ActionMessages
Hi Amin, Writting this: ActionMessage message = new ActionMessage(Username/Password cannot be empty); will not solve the problem. What you need to do to get rid of the following: ???en_US.Username/Password cannot be empty??? is: 1) Add a key/value pair to your application.properties file: key1=Username/Password cannot be empty 2) You need to change the construction of your ActionMessage: ActionMessage message = new ActionMessage(key1); This will solve you problem. Good luck. Aladin Kaizar Amin wrote: Hi Atta, As per your suggestions, I changed the code to if (username == null || username.trim().length() ==0 ){ ActionMessages messages = new ActionMessages(); ActionMessage message = new ActionMessage(Username/Password cannot be empty); messages.add(ActionMessages.GLOBAL_MESSAGE, message); saveMessages(request,messages); But even this doesnt solve my problem. The output I get is: ???en_US.Username/Password cannot be empty??? Hi there, try this: if (username == null || username.trim().length() == 0){ ActionMessages messages = new ActionMessages(); ActionMessage message = new ActionMessage(credentials.empty); messages.add(ActioneMessages.GLOBAL_ERROR, message); saveMessages(request,messages); } Basically, the thing to note here that ActionMessage takes a key from the resource file which I assumed credentails.empty is. The first parameter of the ActionMessges.add(...) is the property against which error is being stored or the generic global_error constant. HTH. ATTA On 9/27/05, Kaizar Amin [EMAIL PROTECTED] wrote: Hello all, I am facing a wierd problem in my application. I want to add an ActionMessage in the ACTION (LoginAction) class and then display the message in the JSP page. In the JSP page, the messages are found without a problem (so my ApplicationResources.properties configuration is fine), however while prinintg them, the string ???en_US and ??? gets attached to my message before and after respectively. ???en_US.my-message??? How do I get rid of these strings??? I searched the discussion-list for similar problems/solutions and found this thread: http://www.mail-archive.com/user@struts.apache.org/msg27565.html However, the solution in that threads talks about using the presentation logic as follows: html:messages id=errmsgs libean:write name=errmsgs//li /html:messages But thats exactly how I am doing also. But for me it still gives the error. Below is the configuration and code snippets that I am using: In struts-config,xml === message-resources parameter=myApp.ApplicationResources null=false/ In LoginAction.java === if (username == null || username.trim().length() == 0){ ActionMessages messages = new ActionMessages(); ActionMessage message = new ActionMessage(Username/Password cannot be empty); messages.add(credentials.empty, message); saveMessages(request,messages); In the JSP page === html:messages id=message message=true div class=success bean:write name=message/br /divbr/ /html:messages The output I get is === ???en_US.Username/Password cannot be empty??? - 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]
ActionMessage and bundle choice
Hi, We know that ActionMessage class has a field to store the key of the message but not the bundle name of the key. For (error) messages that are not in the default message-resources, we can do the trick in the jsp file by giving the bundle of the key like: html:messages bundle=core id=msg bean:write name=msg/ /html:messages So far so good. But, what we shall do if the ActionMessages contain messages which have to be resolved from different bundles? Should we write several html:messages tags with different bundles?
Re: How to remove the unwanted ???en_US string from ActionMessages
when you construct your ActionMessage the first parameter is the key into the MessageResource.. the second parameter is the resource OR string literal you wish to supply assuming message-resource parameter=classname [null=true|false] [key=name] html lang=en in this case if resource is true then your app will reference the key value (name) located within $webapp_home/classes/com/OrganisationName/app_en.properties HTH, Martin- - Original Message - From: Kaizar Amin [EMAIL PROTECTED] To: atta-ur rehman [EMAIL PROTECTED] Cc: Struts Users Mailing List user@struts.apache.org Sent: Tuesday, September 27, 2005 7:20 AM Subject: Re: How to remove the unwanted ???en_US string from ActionMessages Hi Atta, As per your suggestions, I changed the code to if (username == null || username.trim().length() ==0 ){ ActionMessages messages = new ActionMessages(); ActionMessage message = new ActionMessage(Username/Password cannot be empty); messages.add(ActionMessages.GLOBAL_MESSAGE, message); saveMessages(request,messages); But even this doesnt solve my problem. The output I get is: ???en_US.Username/Password cannot be empty??? Hi there, try this: if (username == null || username.trim().length() == 0){ ActionMessages messages = new ActionMessages(); ActionMessage message = new ActionMessage(credentials.empty); messages.add(ActioneMessages.GLOBAL_ERROR, message); saveMessages(request,messages); } Basically, the thing to note here that ActionMessage takes a key from the resource file which I assumed credentails.empty is. The first parameter of the ActionMessges.add(...) is the property against which error is being stored or the generic global_error constant. HTH. ATTA On 9/27/05, Kaizar Amin [EMAIL PROTECTED] wrote: Hello all, I am facing a wierd problem in my application. I want to add an ActionMessage in the ACTION (LoginAction) class and then display the message in the JSP page. In the JSP page, the messages are found without a problem (so my ApplicationResources.properties configuration is fine), however while prinintg them, the string ???en_US and ??? gets attached to my message before and after respectively. ???en_US.my-message??? How do I get rid of these strings??? I searched the discussion-list for similar problems/solutions and found this thread: http://www.mail-archive.com/user@struts.apache.org/msg27565.html However, the solution in that threads talks about using the presentation logic as follows: html:messages id=errmsgs libean:write name=errmsgs//li /html:messages But thats exactly how I am doing also. But for me it still gives the error. Below is the configuration and code snippets that I am using: In struts-config,xml === message-resources parameter=myApp.ApplicationResources null=false/ In LoginAction.java === if (username == null || username.trim().length() == 0){ ActionMessages messages = new ActionMessages(); ActionMessage message = new ActionMessage(Username/Password cannot be empty); messages.add(credentials.empty, message); saveMessages(request,messages); In the JSP page === html:messages id=message message=true div class=success bean:write name=message/br /divbr/ /html:messages The output I get is === ???en_US.Username/Password cannot be empty??? - 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]
Help needed urgent
Hi all, I am trying to list some names (with and ID code) and I want for each name listed create a link, then when the user clicks on the link I want to edit the record (the bean). With this I have my list there with all the names: http://localhost:8080/ExemploStruts/ListagemClientes.do The problem is when I click on the name/link and it should call an action in my DispatchAction, but it gives me an error on the server: HTTP Status 404 - /CadastroClienteDispatchAction.do *type* Status report *message* _/CadastroClienteDispatchAction.do_ *description* _The requested resource (/CadastroClienteDispatchAction.do) is not available._ Apache Tomcat/5.5.8 For listing the names I am using an this Action, which is org.apache.struts.action.ActionForm type: action path=/ListagemClientes type=br.com.manager.action.ListagemClientesAction forward path=/pages/dadosCliente.jsp name=sucesso / forward path=/pages/erros.jsp name=falha / /action For my CRUD operations I am using an action of type org.apache.struts.actions.DispatchAction: action input=/pages/cadastroCliente.jsp name=ClienteForm parameter=acao path=/CadastroClienteDispatchAction scope=session type=br.com.manager.action.ClienteDispatchAction forward name=retorno path=/pages/cadastroCliente.jsp / forward name=sucesso path=/pages/dadosCliente.jsp / forward name=falha path=/pages/erros.jsp / /action This is my .JSP where I create the links: logic:notEmpty name=listagem logic:iterate name=listagem id=lista tr td bgcolor=#E6E8FAa href=/CadastroClienteDispatchAction.do?acao=editarcodigo=bean:write name='lista' property='codigo'/ bean:write name=lista property=nome //a/td td bgcolor=#E6E8FA width=4% align=centera href=/CadastroClienteDispatchAction.do?acao=excluircodigo=bean:write name='lista' property='codigo'/ img src=imagens/lixo.gif border=0/a/td /tr /logic:iterate /logic:notEmpty These are my 2 action in the DispatchAction (excluir=delete, editar=edit) : public ActionForward excluir(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionErrors erros = new ActionErrors(); ActionForward forward = null; ClienteDAO cadastroDAO = new ClienteDAO(this.getConnection()); ClienteFormBean clienteForm = (ClienteFormBean) form; try { cadastroDAO.delete(clienteForm); forward = mapping.findForward(sucesso); } catch (SQLException e) { erros.add(ActionErrors.GLOBAL_ERROR, new ActionError(errors.persistirCadastro, new String[] { e.getMessage() })); forward = mapping.findForward(falha); } catch (Exception e) { erros.add(ActionErrors.GLOBAL_ERROR, new ActionError(errors.persistirCadastro, new String[] { e.getMessage() })); forward = mapping.findForward(falha); } if (!erros.isEmpty()) { saveErrors(request, erros); } return forward; } public ActionForward editar(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionErrors erros = new ActionErrors(); ClienteDAO cadastroDAO = new ClienteDAO(this.getConnection()); ClienteFormBean clienteForm = (ClienteFormBean)form; try { clienteForm = cadastroDAO.getDadosCliente( ((ClienteFormBean)form).getCodigo() ); clienteForm.setAcao(editando); } catch (SQLException e) { erros.add(ActionErrors.GLOBAL_ERROR,new ActionError(errors.recuperarCadastro)); mapping.findForward(falha); } return mapping.findForward(sucesso); } Please, could someone tell me what is wrong OR tell me another way to implement such thing. I am using Struts 1.1 Thanks a lot PS. My Bean and my DAO are working ok. ___ Novo Yahoo! Messenger com voz: ligações, Yahoo! Avatars, novos emoticons e muito mais. Instale agora! www.yahoo.com.br/messenger/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: error using struts.
There could be a problem with message-resources in your struts-config.xml file, the parameter= must refer to a file in your WAR file. Also, check that files referenced in struts-config.xml are included in your WAR file too. -ed On 9/27/05, Carlos de la Flor Egiluz [EMAIL PROTECTED] wrote: Hello i am bigning using struts. i have made one aplication, little application and i have the first error: [27/09/05 12:26:04:688 CEST] 0027 PropertyMessa I Initializing, config=' org.apache.struts.util.LocalStrings', returnNull=true [27/09/05 12:26:04:719 CEST] 0027 PropertyMessa I Initializing, config=' org.apache.struts.action.ActionResources', returnNull=true [27/09/05 12:26:04:844 CEST] 0027 ActionServlet E Parsing error processing resource path [27/09/05 12:26:04:875 CEST] 0027 ActionServlet E TRAS0014I: Se ha anotado cronológicamente la excepción siguiente java.net.MalformedURLException: SRVE0238E: Las vías de accesos de recursos tienen que empezar por una barra inclinada. at com.ibm.ws.webcontainer.webapp.WebApp.getResource(WebApp.java:1915) at com.ibm.ws.webcontainer.facade.ServletContextFacade.getResource( ServletContextFacade.java:100) at org.apache.struts.action.ActionServlet.parseModuleConfigFile( ActionServlet.java:1002) at org.apache.struts.action.ActionServlet.initModuleConfig( ActionServlet.java:955) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:470) at javax.servlet.GenericServlet.init(GenericServlet.java:256) can you help me? thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to make span style= float: right;/ work in Tiles?
梁炳場 wrote: In the header.jsp, I try to add something like About Us, Contact Us. Make them align to the right. But it does not work. I spread across the header section. I do this in the header.jsp (and use classLayout.jsp). tr span style= float;right; / td logic:iterate .. /logic:iterate /td /span /tr How can I make it work? Thnx I guess you didn't cut and paste the code since your style is supposed to be float=right;. HTH, G. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
how to retain prepopulated values in ActionForm
Hi all, I need to show some prefilled value in a html form then take new inputs from the user and save the changes. I am doing this by prepopulating an ActionForm, putting it into request as an Attribute then displaying it onto the jsp. Its working fine and the changed value are also available in next Action. But the problem arises when some error is returned by ActionForm.validate() method In this case the same jsp is shown but the prepopulated values are gone. Is there any way to keep the prepopulated values in the jsp when input jsp is shown due to ActionErrors returned by validate() method. Do I need to store the prepopulated ActionForm in session instead of request? --RahulJoshi
Re: Why the message in ApplicationResources cannot be retrieved?
Hi all, I got the error message of Cannot find ActionMappings or ActionFormBeans collection, Can anyone tell me how to handle this kind of question. btw, I am a newbie of Struts. A piece of struts config file is as following: form-bean name=3DlogonForm type=3Dcn.xjtu.icst.form.LogonForm /form-bean .. action path=3D/logon name=3DlogonForm type=3Dcn.xjtu.icst.LogonAction scope=3Drequest forward name=3Dsuccess path=3D/index.jsp redirect=3Dtrue/ forward name=3Dfailure path=3D/logon.jsp redirect=3Dtrue/ /action Thanks in advance.
How to reference pages external to a webapp using Tiles
I am working on an export coltrol system for the swedish customs. We are using struts and the tiles framework. We would like to have a separate webapp (or even a plain html site) with some standard templates for mainly menus. I have placed some images and standardized jsp-files there, these files should be used for all webapps developed. The problem is when I try to reference those jsp-pages in my tiles definitions file as absolute urls, Cannot get request dispatcher for path http://localhost:7001/std/tiles/common/layout.jsp. The referencing webapp is at http://localhost:7001/ex/do/... And the def looks like: definition name=.layout.ecs path=http://localhost:7001/std/tiles/common/layout.jsp; Is there a solution to this or must the standardized pages included in each webapp? Regards Mats Ekberg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ActionMessages with redirect
There are saveErrors() and saveMessages() that accept a session instead of a request object. The items saved here are removed after the request that accesses them. Hubert On 9/27/05, rahul [EMAIL PROTECTED] wrote: Hi all, Just before creating an ActioForward in my Action class, i am storing some messages using SaveErrors(). And I am using ActionForward(String path, boolean redirect) for creating the ActionForward with 'true' value for redirect parameter. My question is by doing this can I display the ActionMessages that I have saved using SaveErrors()? If not then how can I save ActionMessages/ActionErrors so that they are visible to me even after making a redirect? any suggestions? --RahulJoshi - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to retain prepopulated values in ActionForm
When a validation error occurs, the usual intention is to allow the user to correct his/her mistakes by presenting the values that were entered. If you wish to override this behavior, you can manually call validate() by applying some of the techniques Rick Reumann demonstrates in the section Manually call validate and use Request Scope on http://www.reumann.net/struts/articles/request_lists.jsp. Hubert On 9/27/05, rahul [EMAIL PROTECTED] wrote: Hi all, I need to show some prefilled value in a html form then take new inputs from the user and save the changes. I am doing this by prepopulating an ActionForm, putting it into request as an Attribute then displaying it onto the jsp. Its working fine and the changed value are also available in next Action. But the problem arises when some error is returned by ActionForm.validate() method In this case the same jsp is shown but the prepopulated values are gone. Is there any way to keep the prepopulated values in the jsp when input jsp is shown due to ActionErrors returned by validate() method. Do I need to store the prepopulated ActionForm in session instead of request? --RahulJoshi - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help needed urgent
Instead of href=/CadastroClienteDispatchAction.do... Try one of the ff: href=CadastroClienteDispatchAction.do... (relative) href=/ExemploStruts/CadastroClienteDispatchAction.do... (absolute) Hubert On 9/27/05, Francisco - São Paulo - Brazil [EMAIL PROTECTED] wrote: Hi all, I am trying to list some names (with and ID code) and I want for each name listed create a link, then when the user clicks on the link I want to edit the record (the bean). With this I have my list there with all the names: http://localhost:8080/ExemploStruts/ListagemClientes.do The problem is when I click on the name/link and it should call an action in my DispatchAction, but it gives me an error on the server: HTTP Status 404 - /CadastroClienteDispatchAction.do *type* Status report *message* _/CadastroClienteDispatchAction.do_ *description* _The requested resource (/CadastroClienteDispatchAction.do) is not available._ Apache Tomcat/5.5.8 For listing the names I am using an this Action, which is org.apache.struts.action.ActionForm type: action path=/ListagemClientes type=br.com.manager.action.ListagemClientesAction forward path=/pages/dadosCliente.jsp name=sucesso / forward path=/pages/erros.jsp name=falha / /action For my CRUD operations I am using an action of type org.apache.struts.actions.DispatchAction: action input=/pages/cadastroCliente.jsp name=ClienteForm parameter=acao path=/CadastroClienteDispatchAction scope=session type=br.com.manager.action.ClienteDispatchAction forward name=retorno path=/pages/cadastroCliente.jsp / forward name=sucesso path=/pages/dadosCliente.jsp / forward name=falha path=/pages/erros.jsp / /action This is my .JSP where I create the links: logic:notEmpty name=listagem logic:iterate name=listagem id=lista tr td bgcolor=#E6E8FAa href=/CadastroClienteDispatchAction.do?acao=editarcodigo=bean:write name='lista' property='codigo'/ bean:write name=lista property=nome //a/td td bgcolor=#E6E8FA width=4% align=centera href=/CadastroClienteDispatchAction.do?acao=excluircodigo=bean:write name='lista' property='codigo'/ img src=imagens/lixo.gif border=0/a/td /tr /logic:iterate /logic:notEmpty These are my 2 action in the DispatchAction (excluir=delete, editar=edit) : public ActionForward excluir(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionErrors erros = new ActionErrors(); ActionForward forward = null; ClienteDAO cadastroDAO = new ClienteDAO(this.getConnection()); ClienteFormBean clienteForm = (ClienteFormBean) form; try { cadastroDAO.delete(clienteForm); forward = mapping.findForward(sucesso); } catch (SQLException e) { erros.add(ActionErrors.GLOBAL_ERROR, new ActionError(errors.persistirCadastro, new String[] { e.getMessage() })); forward = mapping.findForward(falha); } catch (Exception e) { erros.add(ActionErrors.GLOBAL_ERROR, new ActionError(errors.persistirCadastro, new String[] { e.getMessage() })); forward = mapping.findForward(falha); } if (!erros.isEmpty()) { saveErrors(request, erros); } return forward; } public ActionForward editar(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionErrors erros = new ActionErrors(); ClienteDAO cadastroDAO = new ClienteDAO(this.getConnection()); ClienteFormBean clienteForm = (ClienteFormBean)form; try { clienteForm = cadastroDAO.getDadosCliente( ((ClienteFormBean)form).getCodigo() ); clienteForm.setAcao(editando); } catch (SQLException e) { erros.add(ActionErrors.GLOBAL_ERROR,new ActionError(errors.recuperarCadastro)); mapping.findForward(falha); } return mapping.findForward(sucesso); } Please, could someone tell me what is wrong OR tell me another way to implement such thing. I am using Struts 1.1 Thanks a lot PS. My Bean and my DAO are working ok. ___ Novo Yahoo! Messenger com voz: ligações, Yahoo! Avatars, novos emoticons e muito mais. Instale agora! www.yahoo.com.br/messenger/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands,
Re: how to retain prepopulated values in ActionForm
If the form is returned after validation, the fields should be refilled with whatever the user submitted, unless your input somehow causes a new request to be created. After validation, Struts has done exactly what you did to prefill the form: instantiate a form bean, populate properties, and place it into request or session scope under the name associated with the validating action mapping. Is your input somehow causing a new request to be created? This might lead to the values being forgotten. (A quick test of that might be to switch the scope of the validating action mapping to session, at least to see what happens.) Sometimes there are other components of a form (like a select menu) which are prepared by a prepopulation action but which are not properly form properties, and those don't automatically get re-established in a case like this -- is that what's happening to you? There are a few solutions for that, but rather than clutter this message, lets see if that is the issue or if I'm misunderstanding you. Joe At 6:44 PM +0530 9/27/05, rahul wrote: Hi all, I need to show some prefilled value in a html form then take new inputs from the user and save the changes. I am doing this by prepopulating an ActionForm, putting it into request as an Attribute then displaying it onto the jsp. Its working fine and the changed value are also available in next Action. But the problem arises when some error is returned by ActionForm.validate() method In this case the same jsp is shown but the prepopulated values are gone. Is there any way to keep the prepopulated values in the jsp when input jsp is shown due to ActionErrors returned by validate() method. Do I need to store the prepopulated ActionForm in session instead of request? --RahulJoshi -- Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com Narrow minds are weapons made for mass destruction -The Ex - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re:problem with html:form tag action property
Check if you have the following servlet-mapping entry in your web.xml. web-app servlet ... /servlet servlet-mapping servlet-nameaction/servlet-name url-pattern*.do/url-pattern /servlet-mapping /web-app Then in your form, you don't need to suffix .do, Struts will do that for you: html:form action=timeTrackingReport ... Cheers, Catherine - a href=http://Struts_User_List.roomity.com;roomity.com/a roomity.com is broadband internet. ~~1127829746411~~ -
RE: Re: using el to assign value of collection attribute in html:options
optionsCollection works! Thanks. -Original Message- From: Wendy Smoak [mailto:[EMAIL PROTECTED] Sent: Monday, September 26, 2005 2:35 PM To: Struts Users Mailing List Subject: Re: Re: using el to assign value of collection attribute in html:options clip The collection attribute is interpreted as the name of a JSP bean, in some scope, that itself represents a collection of individual beans, one per option value to be rendered. If you can't get html:options to cooperate, scroll down the page and look at html:optionsCollection. Sometimes it's easier to figure out what to use for each attribute with that one. /clip - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re:bean:write tag within html:link tag
I thought rahul wanted a href=/myapp/someAction.do?id=/foo/ to invoke someAction and passing a parameter, id. What will happen if you click a hred=/foo/? I still can't figure out how to solve my problem, that is get bean:message tag evaluated as the parameter of a javascript call. Like the following: html:submit onclick=setSubmitAction(bean:message key=MyPanel.theField.label/)bean:message key=MyPanel.theField.label//htm:submit Some time I also need to pass a java variable as the parameter to a javascript function, and I encounter the same problem. For example, html:submit onclick=setSubmitAction(%= myVar %) myVar will not get evaluated. Can someone shied some lights on this? Thanks a lot, Catherine - a href=http://Struts_User_List.roomity.com;roomity.com/a roomity.com is broadband internet. ~~1127830842502~~ -
RE: ActionMessages with redirect
do I need to clean up session after displaying ActionErrors saved using saveErrors(request,actionError) method? -Original Message- From: Hubert Rabago [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 27, 2005 7:09 PM To: Struts Users Mailing List Subject: Re: ActionMessages with redirect There are saveErrors() and saveMessages() that accept a session instead of a request object. The items saved here are removed after the request that accesses them. Hubert On 9/27/05, rahul [EMAIL PROTECTED] wrote: Hi all, Just before creating an ActioForward in my Action class, i am storing some messages using SaveErrors(). And I am using ActionForward(String path, boolean redirect) for creating the ActionForward with 'true' value for redirect parameter. My question is by doing this can I display the ActionMessages that I have saved using SaveErrors()? If not then how can I save ActionMessages/ActionErrors so that they are visible to me even after making a redirect? any suggestions? --RahulJoshi - 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: Help needed urgent
When I tryed this way: href=CadastroClienteDispatchAction.do... HTTP Status 400 - Invalid path /pages/CadastroClienteDispatchAction was requested *type* Status report *message* _Invalid path /pages/CadastroClienteDispatchAction was requested_ *description* _The request sent by the client was syntactically incorrect (Invalid path /pages/CadastroClienteDispatchAction was requested)._ When I tryed this way it worked: href=/ExemploStruts/CadastroClienteDispatchAction.do... But it did not populate my form with the values in the bean and it seems to invoke an submit imediately after loading. As it didnt populate the form with data and some fields are validated/required the errors messages are shown. Maybe something in here, could you have a look please? public ActionForward editar(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionErrors erros = new ActionErrors(); ClienteDAO cadastroDAO = new ClienteDAO(this.getConnection()); ClienteFormBean clienteForm = (ClienteFormBean)form; try { clienteForm = cadastroDAO.getDadosCliente( ((ClienteFormBean)form).getCodigo() ); clienteForm.setAcao(editando); } catch (SQLException e) { erros.add(ActionErrors.GLOBAL_ERROR,new ActionError(errors.recuperarCadastro)); mapping.findForward(falha); } return mapping.findForward(sucesso); } Hubert Rabago escreveu: Instead of href=/CadastroClienteDispatchAction.do... Try one of the ff: href=CadastroClienteDispatchAction.do... (relative) href=/ExemploStruts/CadastroClienteDispatchAction.do... (absolute) Hubert On 9/27/05, Francisco - São Paulo - Brazil [EMAIL PROTECTED] wrote: Hi all, I am trying to list some names (with and ID code) and I want for each name listed create a link, then when the user clicks on the link I want to edit the record (the bean). With this I have my list there with all the names: http://localhost:8080/ExemploStruts/ListagemClientes.do The problem is when I click on the name/link and it should call an action in my DispatchAction, but it gives me an error on the server: HTTP Status 404 - /CadastroClienteDispatchAction.do *type* Status report *message* _/CadastroClienteDispatchAction.do_ *description* _The requested resource (/CadastroClienteDispatchAction.do) is not available._ Apache Tomcat/5.5.8 For listing the names I am using an this Action, which is org.apache.struts.action.ActionForm type: action path=/ListagemClientes type=br.com.manager.action.ListagemClientesAction forward path=/pages/dadosCliente.jsp name=sucesso / forward path=/pages/erros.jsp name=falha / /action For my CRUD operations I am using an action of type org.apache.struts.actions.DispatchAction: action input=/pages/cadastroCliente.jsp name=ClienteForm parameter=acao path=/CadastroClienteDispatchAction scope=session type=br.com.manager.action.ClienteDispatchAction forward name=retorno path=/pages/cadastroCliente.jsp / forward name=sucesso path=/pages/dadosCliente.jsp / forward name=falha path=/pages/erros.jsp / /action This is my .JSP where I create the links: logic:notEmpty name=listagem logic:iterate name=listagem id=lista tr td bgcolor=#E6E8FAa href=/CadastroClienteDispatchAction.do?acao=editarcodigo=bean:write name='lista' property='codigo'/ bean:write name=lista property=nome //a/td td bgcolor=#E6E8FA width=4% align=centera href=/CadastroClienteDispatchAction.do?acao=excluircodigo=bean:write name='lista' property='codigo'/ img src=imagens/lixo.gif border=0/a/td /tr /logic:iterate /logic:notEmpty These are my 2 action in the DispatchAction (excluir=delete, editar=edit) : public ActionForward excluir(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionErrors erros = new ActionErrors(); ActionForward forward = null; ClienteDAO cadastroDAO = new ClienteDAO(this.getConnection()); ClienteFormBean clienteForm = (ClienteFormBean) form; try { cadastroDAO.delete(clienteForm); forward = mapping.findForward(sucesso); } catch (SQLException e) { erros.add(ActionErrors.GLOBAL_ERROR, new ActionError(errors.persistirCadastro, new String[] { e.getMessage() })); forward = mapping.findForward(falha); } catch (Exception e) { erros.add(ActionErrors.GLOBAL_ERROR,
Re: ActionMessages with redirect
No, it gets cleaned up by the RequestProcessor after you've displayed the messages. Hubert On 9/27/05, rahul [EMAIL PROTECTED] wrote: do I need to clean up session after displaying ActionErrors saved using saveErrors(request,actionError) method? -Original Message- From: Hubert Rabago [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 27, 2005 7:09 PM To: Struts Users Mailing List Subject: Re: ActionMessages with redirect There are saveErrors() and saveMessages() that accept a session instead of a request object. The items saved here are removed after the request that accesses them. Hubert On 9/27/05, rahul [EMAIL PROTECTED] wrote: Hi all, Just before creating an ActioForward in my Action class, i am storing some messages using SaveErrors(). And I am using ActionForward(String path, boolean redirect) for creating the ActionForward with 'true' value for redirect parameter. My question is by doing this can I display the ActionMessages that I have saved using SaveErrors()? If not then how can I save ActionMessages/ActionErrors so that they are visible to me even after making a redirect? any suggestions? --RahulJoshi - 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]
Can I replace the link jsp file with an action path in Tiles definition file?
Can I replace the link jsp file with an action path? thnx definition name=erp.menu.left path=/common/layout/verticalMenu.jsp put name=title value=Us / putList name=items item value=About UsLINK=/foo.jsp / item value=Contact Us LINK=/foo.jsp / /putList /definition - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help needed urgent
On 9/27/05, Francisco - São Paulo - Brazil [EMAIL PROTECTED] wrote: When I tryed this way: href=CadastroClienteDispatchAction.do... HTTP Status 400 - Invalid path /pages/CadastroClienteDispatchAction was requested This is because your JSP and your actions are in different paths. When I tryed this way it worked: href=/ExemploStruts/CadastroClienteDispatchAction.do... But it did not populate my form with the values in the bean Did you include the parameters you wanted to populate? a href=/ExemploStruts//CadastroClienteDispatchAction.do?acao=editarcodigo=bean:write name='lista' property='codigo'/ and it seems to invoke an submit imediately after loading. Isn't this a link? So when you click it, it will immediately load the resource referenced by the link. I'm not sure I understand your concern. As it didnt populate the form with data and some fields are validated/required the errors messages are shown. This is the expected behavior when there's a validation error. Once the issue about why you're having validation problems are solved, you shouldn't see this problem anymore. Maybe something in here, could you have a look please? My guess is the problem lies outside your Action code, since you specify acao=editar in your request, acao is the parameter for your DispatchAction, and you have an editar method. Are you able to call normal Struts actions okay? Hubert - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help needed urgent
My guess is the problem lies outside your Action code, since you specify acao=editar in your request, acao is the parameter for your DispatchAction, and you have an editar method. Are you able to call normal Struts actions okay? Yes, I am able, for example, to save data from the form, as follow: public ActionForward salvar(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionErrors erros = new ActionErrors(); ActionForward forward = null; ClienteDAO cadastroDAO = new ClienteDAO(this.getConnection()); ClienteFormBean clienteForm = (ClienteFormBean) form; try { cadastroDAO.insert(clienteForm); forward = mapping.findForward(sucesso); request.setAttribute(resultado, O Cliente foi salvo com sucesso.); } catch (SQLException e) { e.printStackTrace(); erros.add(ActionErrors.GLOBAL_ERROR, new ActionError(errors.persistirCadastro, new String[] { e.getMessage() })); forward = mapping.findForward(falha); } catch (Exception e) { e.printStackTrace(); erros.add(ActionErrors.GLOBAL_ERROR, new ActionError(errors.persistirCadastro, new String[] { e.getMessage() })); forward = mapping.findForward(falha); } if (!erros.isEmpty()) { saveErrors(request, erros); } request.getSession().invalidate(); return forward; } html:hidden property=acao value=error / html:submit styleClass=caixaPontilhada onclick=setMetodo('salvar'); style=width:150px; bean:message key=botao.enviar / /html:submit Could you point me what are the steps to perform this I am trying?? Then I will check everything here. Thanks Francisco Hubert Rabago escreveu: On 9/27/05, Francisco - São Paulo - Brazil [EMAIL PROTECTED] wrote: When I tryed this way: href=CadastroClienteDispatchAction.do... HTTP Status 400 - Invalid path /pages/CadastroClienteDispatchAction was requested This is because your JSP and your actions are in different paths. When I tryed this way it worked: href=/ExemploStruts/CadastroClienteDispatchAction.do... But it did not populate my form with the values in the bean Did you include the parameters you wanted to populate? a href=/ExemploStruts//CadastroClienteDispatchAction.do?acao=editarcodigo=bean:write name='lista' property='codigo'/ and it seems to invoke an submit imediately after loading. Isn't this a link? So when you click it, it will immediately load the resource referenced by the link. I'm not sure I understand your concern. As it didnt populate the form with data and some fields are validated/required the errors messages are shown. This is the expected behavior when there's a validation error. Once the issue about why you're having validation problems are solved, you shouldn't see this problem anymore. Maybe something in here, could you have a look please? My guess is the problem lies outside your Action code, since you specify acao=editar in your request, acao is the parameter for your DispatchAction, and you have an editar method. Are you able to call normal Struts actions okay? Hubert - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ___ Novo Yahoo! Messenger com voz: ligações, Yahoo! Avatars, novos emoticons e muito mais. Instale agora! www.yahoo.com.br/messenger/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: problem with html:form tag action property
Yes I have that mapping. The form tag is not working irrespective of whether the .do suffix is there. -Original Message- From: Catherine [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 27, 2005 10:02 AM To: user@struts.apache.org Subject: Re:problem with html:form tag action property Check if you have the following servlet-mapping entry in your web.xml. web-app servlet ... /servlet servlet-mapping servlet-nameaction/servlet-name url-pattern*.do/url-pattern /servlet-mapping /web-app Then in your form, you don't need to suffix .do, Struts will do that for you: html:form action=timeTrackingReport ... Cheers, Catherine - a href=http://Struts_User_List.roomity.com;roomity.com/a roomity.com is broadband internet. ~~1127829746411~~ - - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
using html:option tag
Hi All, I am using the html option tag embedded within the html select tag to select a value from a drop down list as follows: html:select property=title html:option value=MrMr/html:option html:option value=MrsMrs/html:option /html:select This works fine and I can save the correct value to the database. The question I have is how do I display the same option tag when updating the user and the details are returned from a database. So in plain English after the user has saved the client to the db he then wants to update the record. A search is done but how do I display on the JSP page the selected option with the option of seleting something else from the drop down list. Thanks in advance
writing images from a database
Goal: Read a blob image from an Oracle database and render it on an html page using the struts framework. I've never found a good way to do this and I was hoping someone had a best practice suggestion. I have no trouble getting the image from the database. However, I wonder if there isn't a better way to display it rather than writing it to a physical file and then rendering it. I'm using the html:img tag to display the image now. All help appreciated. J. ImputStream pictureStream; ResultSet rs; // create the query and execute it ... // get the result pictureStream = rs.getBinaryStream(picture); // I can write it to a physical file File pictureFile = new File(/temp/picture.jpg); try { FileOutputStream out = new FileOutputStream(pictureFile); int chunk = 0; while( (chunk = pictureStream.read()) != -1) { out.write(chunk); } out.close(); out.flush(); } catch(FileNotFoundException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } catch(IOException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } -- This transmission is intended only for use by the addressee(s) named herein and may contain information that is proprietary, confidential and/or legally privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: writing images from a database
I've seen this conversation before so I don't think I am saying anything outlandish here. There is a performance overhead from reading a database to present to the JSP page, however you look at it. There is nothing wrong with writing the image once to the file system, and storing a reference to the image on the file system. -Original Message- From: Braun, James F [mailto:[EMAIL PROTECTED] Sent: 27 September 2005 17:24 To: Struts Users Mailing List Subject: writing images from a database Goal: Read a blob image from an Oracle database and render it on an html page using the struts framework. I've never found a good way to do this and I was hoping someone had a best practice suggestion. I have no trouble getting the image from the database. However, I wonder if there isn't a better way to display it rather than writing it to a physical file and then rendering it. I'm using the html:img tag to display the image now. All help appreciated. J. ImputStream pictureStream; ResultSet rs; // create the query and execute it ... // get the result pictureStream = rs.getBinaryStream(picture); // I can write it to a physical file File pictureFile = new File(/temp/picture.jpg); try { FileOutputStream out = new FileOutputStream(pictureFile); int chunk = 0; while( (chunk = pictureStream.read()) != -1) { out.write(chunk); } out.close(); out.flush(); } catch(FileNotFoundException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } catch(IOException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } -- This transmission is intended only for use by the addressee(s) named herein and may contain information that is proprietary, confidential and/or legally privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. - 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: using html:option tag
From: [EMAIL PROTECTED] This works fine and I can save the correct value to the database. The question I have is how do I display the same option tag when updating the user and the details are returned from a database. The same JSP snippet you posted should work in both the 'add' and 'edit' forms. For select list contents that are the same for every user, I use a ServletContextListener to place collections in application scope, and then use html:options or html:optionsCollection. This avoids hard-coding the list of options. -- Wendy Smoak - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using html:option tag
The html:select tag has an attribute value. http://struts.apache.org/userGuide/struts-html.html#select The value to compare with for marking an option selected. [RT Expr] HTH, Glenn [EMAIL PROTECTED] 27/09/2005 12:08 PM Please respond to Struts Users Mailing List user@struts.apache.org To user@struts.apache.org cc Subject using html:option tag Hi All, I am using the html option tag embedded within the html select tag to select a value from a drop down list as follows: html:select property=title html:option value=MrMr/html:option html:option value=MrsMrs/html:option /html:select This works fine and I can save the correct value to the database. The question I have is how do I display the same option tag when updating the user and the details are returned from a database. So in plain English after the user has saved the client to the db he then wants to update the record. A search is done but how do I display on the JSP page the selected option with the option of seleting something else from the drop down list. Thanks in advance
Re: CactusStrutsTestCase working problem with tiles extension
Thank you Richard for the answering... Since my app is written in a lower J2EE version so I have to use strutstest_2.0.0.jar which doesn't support verifyTilesForward() method. Any other suggestions? Thanks. Richard Yee [EMAIL PROTECTED] wrote: Carl, Check the CactusStrutsTestCase javadoc. You should use verifyTilesForward instead of verifyForward(). There is also a verifyInputTilesForward() too. -Richard Carl Smith wrote: Is there any helps here? Thank you in advance. Carl Smith wrote: I am sorry for this a little long question, but you will be finding it interesting... Simply put, I have (1),(2) and (3), then we I run struts testing, I got error described as (4) (1) item in struts-config.xml type=my.actions.myAction name=myForm scope=request validate=true input=myInput (2) item in tiles-defs.xml (3) I was trying to test MyAction.java (not shown here since it is just some simple stuff), I wrote the following struts testing case: public class MyActionTest extends CactusStrutsTestCase { public MyActionTest(String testingName){ super(testingName); } public void begin(WebRequest req){ req.setAuthentication(new BasicAuthentication(username,password)); } public void testDisplay() throws Exception { setRequestPathInfo(/MyAction); actionPerform(); // after actionPerform(), MyAction is really forwarding to myApp.display.page // so the testing should have passed, but it did not, see below error verifyForward(display); } } (4) junit.framework.AssertionFailedError: was expecting '/myContentRoot/myApp.display.page' but received '/myContentRoot/jsp/default.jsp' at servletunit.struts.Common.verifyForwardPath(Common.java:170) at servletunit.struts.CactusStrutsTestCase.verifyForward(CactusStrutsTestCase.java:432) However, if I delete extends=myDefault from the configure for myApp.display.page in tiles-defs.xml, then the test case passed. It seems there is an issue with the tiles extend, why this is happening? Do you have any idea or workaround? - Yahoo! for Good Click here to donate to the Hurricane Katrina relief effort. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Yahoo! for Good Click here to donate to the Hurricane Katrina relief effort.
Re: writing images from a database
From: Braun, James F [EMAIL PROTECTED] Goal: Read a blob image from an Oracle database and render it on an html page using the struts framework. I have no trouble getting the image from the database. However, I wonder if there isn't a better way to display it rather than writing it to a physical file and then rendering it. I'm using the html:img tag to display the image now. When the browser encounters an img tag, it makes a separate request to the server for the image. You can map that request to whatever you want-- I would use a Servlet-- and write the bytes of the image out to the browser. I do this with JFreeChart to display a pie chart, but the basics are the same whether you read the image from a database or create it on the fly. If you want to use an Action, (maybe you need some values from the form bean to figure out what image to load,) you can 'take over' the response, and then return null from the execute method to tell the framework that it doesn't need to do anything else with the response. For images that don't change, there should be some sort of caching mechanism in place so you're not constantly going back to the database for the same image. -- Wendy Smoak - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: writing images from a database
You need to put in a bit more buffering, etc. in this code, Mark. I recommend you read up on how to read and to write to files more efficiently. Also, due to the nature of how computers work, I would highly recommend you create a multi-threaded application to do this. You will find that your performance will be hugely impacted. On 9/27/05, Mark Benussi [EMAIL PROTECTED] wrote: I've seen this conversation before so I don't think I am saying anything outlandish here. There is a performance overhead from reading a database to present to the JSP page, however you look at it. There is nothing wrong with writing the image once to the file system, and storing a reference to the image on the file system. -Original Message- From: Braun, James F [mailto:[EMAIL PROTECTED] Sent: 27 September 2005 17:24 To: Struts Users Mailing List Subject: writing images from a database Goal: Read a blob image from an Oracle database and render it on an html page using the struts framework. I've never found a good way to do this and I was hoping someone had a best practice suggestion. I have no trouble getting the image from the database. However, I wonder if there isn't a better way to display it rather than writing it to a physical file and then rendering it. I'm using the html:img tag to display the image now. All help appreciated. J. ImputStream pictureStream; ResultSet rs; // create the query and execute it ... // get the result pictureStream = rs.getBinaryStream(picture); // I can write it to a physical file File pictureFile = new File(/temp/picture.jpg); try { FileOutputStream out = new FileOutputStream(pictureFile); int chunk = 0; while( (chunk = pictureStream.read()) != -1) { out.write(chunk); } out.close(); out.flush(); } catch(FileNotFoundException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } catch(IOException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } -- This transmission is intended only for use by the addressee(s) named herein and may contain information that is proprietary, confidential and/or legally privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. - 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] -- You can lead a horse to water but you cannot make it float on its back. ~Dakota Jack~ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: writing images from a database
The Wiki is your friend: http://wiki.apache.org/struts/StrutsFileDownload Specifically, you will be interested in the downloadapp.zip sample I posted there... it has an example of serving a BLOB from a database. All you need to do is have a mapping to this Action, and use it as the src attribute of an img tag. As another poster said though, there is definitely a fair amount of overhead to doing this. That being said, I've done it to good effect on at least two occassions. But, you do have to think about whether it is appropriate... in my case, it was a client's logo in a frame that only changed when the user changed clients, very infrequent. I can't imagine I'd serve images from a database if it was going to be needed a lot... I'd have to have an exceptionally good reason for doing it. Maybe you do :) In any case, that sample app should show you how. Note too that even if you aren't using a version of Struts with the DownloadAction, what's there is still somewhat applicable, and there's nothing to stop you from bringing DownloadAction over to your app anyway AFAIK. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com On Tue, September 27, 2005 12:23 pm, Braun, James F said: Goal: Read a blob image from an Oracle database and render it on an html page using the struts framework. I've never found a good way to do this and I was hoping someone had a best practice suggestion. I have no trouble getting the image from the database. However, I wonder if there isn't a better way to display it rather than writing it to a physical file and then rendering it. I'm using the html:img tag to display the image now. All help appreciated. J. ImputStream pictureStream; ResultSet rs; // create the query and execute it ... // get the result pictureStream = rs.getBinaryStream(picture); // I can write it to a physical file File pictureFile = new File(/temp/picture.jpg); try { FileOutputStream out = new FileOutputStream(pictureFile); int chunk = 0; while( (chunk = pictureStream.read()) != -1) { out.write(chunk); } out.close(); out.flush(); } catch(FileNotFoundException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } catch(IOException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } -- This transmission is intended only for use by the addressee(s) named herein and may contain information that is proprietary, confidential and/or legally privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. - 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]
Authentication base on Form
Hi! I am trying to switch on the authentication based on Form, but it isn't possible... the redirection to the Login page no work. Could anyone help me Alicia
Re: Authentication base on Form
López Díaz wrote: I am trying to switch on the authentication based on Form, but it isn't possible... the redirection to the Login page no work. Could anyone help me Not yet. In order to help I suspect we'd need a bit more information, like... what specifically happens. Things like that. Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ValidWhen and string comparison
Hello, I try to use the validator with validwhen. I want to use a string comparison but it fails. I use struts 1.2.7 and here is my validators.xml: !DOCTYPE form-validation PUBLIC -//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd; form-validation formset form name=finSaisie field property=financement depends=validwhen arg0 key=gwiad.libelle.financement/ var var-nametest/var-name var-value(statut==Doctorant)/var-value /var /field /form /formset /form-validation I gess it means that the field 'financement' is valid when the field 'statut' is Doctorant. But it is never valid... I tested with success integer comparison and the null comparison but I can't use string comparison. But the struts documentation tells it is possible and some users in this mailing list use string comparison with success. So what can I do? Thanx, Manu. -- Emmanuel Leguy LIFL - UMR8022 CNRS - Bat M3 Tel: +33 3 28 77 85 32 USTL - Universite de Lille 1 Fax: +33 3 28 77 85 37 59655 VILLENEUVE D'ASCQ CEDEX - FRANCE mailto:[EMAIL PROTECTED] http://www.lifl.fr/ANNUAIRE/employee.php?login=leguye Ce mail est signe par un certificat X509 fourni par le CNRS La verification de ce certificat peut etre faite a l'adresse suivante: http://igc.services.cnrs.fr/CNRS-Standard/recherche.html smime.p7s Description: S/MIME Cryptographic Signature
RE: problem with html:form tag action property
Problem solved. The problem was due to the ordering of tags in our web.xml. When I rearranged the servlet-mappings for our action servlet so the *.do pattern is specified last, the form tag generates a correct action property: servlet-nameaction/servlet-name url-patternMain.jsp/url-pattern /servlet-mapping servlet-nameaction/servlet-name url-pattern*.do/url-pattern /servlet-mapping -Original Message- From: Jane Eisenstein [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 27, 2005 12:06 PM To: Struts Users Mailing List Subject: RE: problem with html:form tag action property Yes I have that mapping. The form tag is not working irrespective of whether the .do suffix is there. -Original Message- From: Catherine [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 27, 2005 10:02 AM To: user@struts.apache.org Subject: Re:problem with html:form tag action property Check if you have the following servlet-mapping entry in your web.xml. web-app servlet ... /servlet servlet-mapping servlet-nameaction/servlet-name url-pattern*.do/url-pattern /servlet-mapping /web-app Then in your form, you don't need to suffix .do, Struts will do that for you: html:form action=timeTrackingReport ... Cheers, Catherine - a href=http://Struts_User_List.roomity.com;roomity.com/a roomity.com is broadband internet. ~~1127829746411~~ - - 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: problem with html:form tag action property
Jane, If I recall correctly, struts overrides the pattern each time, only using the LAST url pattern. So be careful! Regards, David -Original Message- From: Jane Eisenstein [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 27, 2005 2:10 PM To: Struts Users Mailing List Subject: RE: problem with html:form tag action property Problem solved. The problem was due to the ordering of tags in our web.xml. When I rearranged the servlet-mappings for our action servlet so the *.do pattern is specified last, the form tag generates a correct action property: servlet-nameaction/servlet-name url-patternMain.jsp/url-pattern /servlet-mapping servlet-nameaction/servlet-name url-pattern*.do/url-pattern /servlet-mapping -Original Message- From: Jane Eisenstein [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 27, 2005 12:06 PM To: Struts Users Mailing List Subject: RE: problem with html:form tag action property Yes I have that mapping. The form tag is not working irrespective of whether the .do suffix is there. -Original Message- From: Catherine [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 27, 2005 10:02 AM To: user@struts.apache.org Subject: Re:problem with html:form tag action property Check if you have the following servlet-mapping entry in your web.xml. web-app servlet ... /servlet servlet-mapping servlet-nameaction/servlet-name url-pattern*.do/url-pattern /servlet-mapping /web-app Then in your form, you don't need to suffix .do, Struts will do that for you: html:form action=timeTrackingReport ... Cheers, Catherine - a href=http://Struts_User_List.roomity.com;roomity.com/a roomity.com is broadband internet. ~~1127829746411~~ - - 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]
iPlanet 6 and Struts 1.2
Platform: iPlante 6.0 (sp2 on Solaris, sp1 on Windows for dev) JVM: 1.2 Struts: 1.2 IDE: IntelliJ 5 I have structs running, but some things don't seem to work (like the JSTL support), but a more important break is the reading of the message properties file. In my struts config I have the following entry: message-resources parameter=com.wh.downy.resources.MessageResources null=false / At the moment, this resource contains the following (actually two copies, one just .properties and the other named _en_US.properties): errors.header=divul errors.footer=/ul/div errors.prefix=li errors.suffix=/li prompt.email=Your e-mails do not match. ppi_form.firstName=Please give your first name. IntelliJ properly sees them as a bundled resource and both show up inthe class path under /WEB-INF/classes under the app space on the server. But when I use html:errors / in a JSP, errors appear one after another and not in a ul. Further, if I try to use a message in a validator, I just get ??message_name_en_US???. How do I get Struts to see the bundle? How can I debug to see? If I run it under Tomcat 5, all is well? Thanks, Bryon - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Authentication base on Form
Buenos Dias López Díaz Also it would be helpful to know the authentication algorithm (jetspeed/oracle single signon) that you are implementing.. Saludos, Martin- - Original Message - From: Dave Newton [EMAIL PROTECTED] To: Struts Users Mailing List user@struts.apache.org Sent: Tuesday, September 27, 2005 1:19 PM Subject: Re: Authentication base on Form López Díaz wrote: I am trying to switch on the authentication based on Form, but it isn't possible... the redirection to the Login page no work. Could anyone help me Not yet. In order to help I suspect we'd need a bit more information, like... what specifically happens. Things like that Dave - 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]
recursive and struts. SOS
hello y have one java object like this (the object name is adressesObj: String name String surname List list = new ArrayList() set/get methods well into the list (arrayList) there are several elements, objects, that are like the same object (adressesObj)... and eah obj has severeal objs.. there is any method, using struts, for, recursively, to load the obj values, the name for all addressesObj? or using jstl? can anybody helps me? thanks
Re: ValidWhen and string comparison
What you have should work - but its always going to give an error unless statut is set to Doctorant. Are you sure statut is in your bean and getting populated? Niall - Original Message - From: Emmanuel.Leguy [EMAIL PROTECTED] To: Struts Users Mailing List user@struts.apache.org Sent: Tuesday, September 27, 2005 6:46 PM Subject: ValidWhen and string comparison Hello, I try to use the validator with validwhen. I want to use a string comparison but it fails. I use struts 1.2.7 and here is my validators.xml: !DOCTYPE form-validation PUBLIC -//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd; form-validation formset form name=finSaisie field property=financement depends=validwhen arg0 key=gwiad.libelle.financement/ var var-nametest/var-name var-value(statut == Doctorant)/var-value /var /field /form /formset /form-validation I gess it means that the field 'financement' is valid when the field 'statut' is Doctorant. But it is never valid... I tested with success integer comparison and the null comparison but I can't use string comparison. But the struts documentation tells it is possible and some users in this mailing list use string comparison with success. So what can I do? Thanx, Manu. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
change the language
hello can anybody helps me to write one action for changin the language? i want to cahge the org.apache.struts.actions.LocaleAction to en or es but i dont know how to programe it. can anybody helps me or say me where can i find one example? thanks
Re: Help needed urgent
You skipped over my other questions: When I tryed this way it worked: href=/ExemploStruts/CadastroClienteDispatchAction.do... But it did not populate my form with the values in the bean Did you include the parameters you wanted to populate? a href=/ExemploStruts//CadastroClienteDispatchAction.do?acao=editarcodigo=bean:write name='lista' property='codigo'/ Also, you said: and it seems to invoke an submit imediately after loading. What did you mean by that statement? Hubert - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamicform field type
Oleg wrote: I found a bunch of posts and articles on dynamic forms but I havent found any tips on how one can dynamically define wheter the field will be html-el:text, html-el:img, .. Bascially something like: html-el:${obj.value.type} property=${obj.value.content} / There's no way to that in JSPs; there's no 'eval' mechanism. Of course a dirty way would be printing out plain html like input type=text :) Yes, you could do that. Another possibility would be to write a JSP 2.0 tag file containing something like c:choose c:when test=${type eq 'text'} html-el:text property=${property} ... /c:when c:when test=${type eq '... and invoke it with tag:mytag type=${obj.value.type} property=${obj.value.content} ... It's cumbersome (and there are some caveats about calling the HTML tags from a tag file if you want to support optional attributes, which I can describe if you're interested). The other way would be write a traditional custom tag in Java and have it call into the existing HTML tags to do its work. L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: change the language
See MailReader Demo Application. On 9/27/05, Carlos de la Flor Egiluz [EMAIL PROTECTED] wrote: hello can anybody helps me to write one action for changin the language? i want to cahge the org.apache.struts.actions.LocaleAction to en or es but i dont know how to programe it. can anybody helps me or say me where can i find one example? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to make img response to a click?
梁炳場 wrote: html:img alt=Powered by Struts page=/images/struts-power.gif / How to make html:img or other html tag response to a click? As in straight HTML, you need to wrap the image (or other content) with a link (a tag in HTML, html:link tag in Struts). html:link page=/actionToInvoke html:image alt=... L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[OT] question about XSL and XPATH
Hi suppose i have a XML file as below, i want to print only value where id = name. I want to do this using XSL, not java program for example once i read throug all the XML file, i should get output as 123 and 456 xml nameabc/name namexyz/name data idabc/id value123/value /data data idxyz/id value456/value /data data idjkl/id value998/value /data /xml This is the XSL i have been trying xsl:for-each select=/ xsl:for-each select=data xsl:if test=name=id what test condition do i put here, this does not work xsl:value-of select=value / /xsl:if /xsl:for-each /xsl:for-each __ Yahoo! for Good Donate to the Hurricane Katrina relief effort. http://store.yahoo.com/redcross-donate3/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: recursive and struts. SOS
Try the tutorials on http://www.keyboardmonkey.com/next/index.jsp Hubert On 9/27/05, Carlos de la Flor Egiluz [EMAIL PROTECTED] wrote: hello y have one java object like this (the object name is adressesObj: String name String surname List list = new ArrayList() set/get methods well into the list (arrayList) there are several elements, objects, that are like the same object (adressesObj)... and eah obj has severeal objs.. there is any method, using struts, for, recursively, to load the obj values, the name for all addressesObj? or using jstl? can anybody helps me? thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [OT] question about XSL and XPATH
Your XSL should be something like: xsl:template match=/data/id/value xsl:value-of select=text()/ /xsl:template Basically, match the node you are interested in and get the text value for that node. -- Christopher Chan SpikeSource, Inc. [EMAIL PROTECTED] http://developer.spikesource.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: recursive and struts. SOS
i dont see any thing for the recursively... can you say me where is? thanks 2005/9/27, Hubert Rabago [EMAIL PROTECTED]: Try the tutorials on http://www.keyboardmonkey.com/next/index.jsp Hubert On 9/27/05, Carlos de la Flor Egiluz [EMAIL PROTECTED] wrote: hello y have one java object like this (the object name is adressesObj: String name String surname List list = new ArrayList() set/get methods well into the list (arrayList) there are several elements, objects, that are like the same object (adressesObj)... and eah obj has severeal objs.. there is any method, using struts, for, recursively, to load the obj values, the name for all addressesObj? or using jstl? can anybody helps me? thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: recursive and struts. SOS
Carlos de la Flor Egiluz wrote: hello y have one java object like this (the object name is adressesObj: String name String surname List list = new ArrayList() set/get methods well into the list (arrayList) there are several elements, objects, that are like the same object (adressesObj)... and eah obj has severeal objs.. there is any method, using struts, for, recursively, to load the obj values, the name for all addressesObj? or using jstl? can anybody helps me? thanks I'm not sure I understand your question... Are you trying to initialize your addressObj object with data from somewhere (like a database)? Or trying to populate it with data submitted in an HTTP request (from a form, for example)? Either way I think the answer is that Struts doesn't know anything about your data structure and therefore can't automatically manage it for you. Perhaps you can explain what you want to do in a bit more detail. L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: writing images from a database
The way I do this is to dynamically control caching on the CLIENT. Some clients have one cache time and others have a different time. Also, for different images, you can use different caching times on the same client. There are lots of ways to fry this fish. On 9/27/05, Frank W. Zammetti [EMAIL PROTECTED] wrote: The Wiki is your friend: http://wiki.apache.org/struts/StrutsFileDownload Specifically, you will be interested in the downloadapp.zip sample I posted there... it has an example of serving a BLOB from a database. All you need to do is have a mapping to this Action, and use it as the src attribute of an img tag. As another poster said though, there is definitely a fair amount of overhead to doing this. That being said, I've done it to good effect on at least two occassions. But, you do have to think about whether it is appropriate... in my case, it was a client's logo in a frame that only changed when the user changed clients, very infrequent. I can't imagine I'd serve images from a database if it was going to be needed a lot... I'd have to have an exceptionally good reason for doing it. Maybe you do :) In any case, that sample app should show you how. Note too that even if you aren't using a version of Struts with the DownloadAction, what's there is still somewhat applicable, and there's nothing to stop you from bringing DownloadAction over to your app anyway AFAIK. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com On Tue, September 27, 2005 12:23 pm, Braun, James F said: Goal: Read a blob image from an Oracle database and render it on an html page using the struts framework. I've never found a good way to do this and I was hoping someone had a best practice suggestion. I have no trouble getting the image from the database. However, I wonder if there isn't a better way to display it rather than writing it to a physical file and then rendering it. I'm using the html:img tag to display the image now. All help appreciated. J. ImputStream pictureStream; ResultSet rs; // create the query and execute it ... // get the result pictureStream = rs.getBinaryStream(picture); // I can write it to a physical file File pictureFile = new File(/temp/picture.jpg); try { FileOutputStream out = new FileOutputStream(pictureFile); int chunk = 0; while( (chunk = pictureStream.read()) != -1) { out.write(chunk); } out.close(); out.flush(); } catch(FileNotFoundException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } catch(IOException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } -- This transmission is intended only for use by the addressee(s) named herein and may contain information that is proprietary, confidential and/or legally privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. - 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] -- You can lead a horse to water but you cannot make it float on its back. ~Dakota Jack~ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: recursive and struts. SOS
On 9/27/05, Laurie Harper [EMAIL PROTECTED] wrote: Carlos de la Flor Egiluz wrote: hello y have one java object like this (the object name is adressesObj: String name String surname List list = new ArrayList() set/get methods well into the list (arrayList) there are several elements, objects, that are like the same object (adressesObj)... and eah obj has severeal objs.. there is any method, using struts, for, recursively, to load the obj values, the name for all addressesObj? or using jstl? can anybody helps me? thanks I'm not sure I understand your question... Are you trying to initialize your addressObj object with data from somewhere (like a database)? Or trying to populate it with data submitted in an HTTP request (from a form, for example)? Either way I think the answer is that Struts doesn't know anything about your data structure and therefore can't automatically manage it for you. Perhaps you can explain what you want to do in a bit more detail. I guess he has a tree of addresses and wants to display addresses for a parent address (and to update them from a page too?). Well Carlos, I guess you can use iterate tag for display along with some scriptlet, but I am not sure that you can update an object tree from a page... Michael. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: dir Attribute in HTML Tag library
yogi wrote: Hi All, This is regarding dir attribute is Struts HTML tag library. The HTML taglib contains tags used to create Struts input forms, as well as other tags generally useful in the creation of HTML-based user interfaces. The output is HTML 4.01 compliant or XHTML 1.0 when in XHTML mode. According to HTML 4.0 specification HTML element has following attribute - !ENTITY % html.content HEAD, BODY !ELEMENT HTML O O ( %html.content;)-- document root element -- !ATTLIST HTML %i18n; -- lang, dir -- --- And struts HTML tag takes following attributes - 1. lang 2. locale 3. xhtml --- THEN HOW I CAN SPECIFY DIR ATTRIBUTE IN STRUTS? Is there any way I can specify this?Please let me know Thanks in Advance -Yogesh Unfortunately the 'html' tag doesn't currently support the 'dir' attribute. It would be easy to add, though. I'd suggest posting an enhancement request to Bugzilla. L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
change the language
Struts Mailreader Demonstration application is included into Struts bundle as struts-mailreader.war. Also check out my implementation: http://www.superinterface.com/mailreader The link on the bottom of the home page explains how it works. Unlike original version, this one has more messages localized, including validator messages. I removed support for Japanese since I don't know it ;-) Michael. On 9/27/05, Carlos de la Flor Egiluz [EMAIL PROTECTED] wrote: where is this example, application? for seeing it. thanks 2005/9/27, Michael Jouravlev [EMAIL PROTECTED]: See MailReader Demo Application. On 9/27/05, Carlos de la Flor Egiluz [EMAIL PROTECTED] wrote: hello can anybody helps me to write one action for changin the language? i want to cahge the org.apache.struts.actions.LocaleAction to en or es but i dont know how to programe it. can anybody helps me or say me where can i find one example? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: change the language
Do you understand how the i18n works with the properties files in Struts? On 9/27/05, Michael Jouravlev [EMAIL PROTECTED] wrote: Struts Mailreader Demonstration application is included into Struts bundle as struts-mailreader.war. Also check out my implementation: http://www.superinterface.com/mailreader The link on the bottom of the home page explains how it works. Unlike original version, this one has more messages localized, including validator messages. I removed support for Japanese since I don't know it ;-) Michael. On 9/27/05, Carlos de la Flor Egiluz [EMAIL PROTECTED] wrote: where is this example, application? for seeing it. thanks 2005/9/27, Michael Jouravlev [EMAIL PROTECTED]: See MailReader Demo Application. On 9/27/05, Carlos de la Flor Egiluz [EMAIL PROTECTED] wrote: hello can anybody helps me to write one action for changin the language? i want to cahge the org.apache.struts.actions.LocaleAction to en or es but i dont know how to programe it. can anybody helps me or say me where can i find one example? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- You can lead a horse to water but you cannot make it float on its back. ~Dakota Jack~ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts action servlet mapping, getPathInfo() returns null
Remember that servlet mapping and action paths are two entirely seperate things. For servlet mappings, *.do/** would be infix, not suffix -- and infix is not allowed. Suffix means, roughly, 'at the end'. In other words, you can either have 'text*' (prefix mapping) or '*text' (suffix mapping). It's one or the other, you can't mix them. So, to use wildcard action paths with suffix mapping, your mapping would be '*.do', your action would be specified like this action path=/my/action/** ... and the URL you would use to access it would look like this http://host/app/my/action/some/path.do The servlet contain matches the entire request URL against your servlet mappings, do it can't match '.../...do/...' because the '.do' is neither at the start of the URL (for prefix mapping) or the end of the URL (for suffix mapping). It's only *after* the contain matches the URL as a whole that it's passed to Struts for matching against your action paths. So, you either use prefix mapping and have something to match at the start of the URL, or you use suffix mapping and have something to match at the end of the URL. Like I said, I haven't tried it with suffix mapping, but that's how it would look in theory. L. emre akbas wrote: Again, thank you very much Laurie. I couldn't understand how ** wildcard mapping could work with suffix mapping (*.do). I have tried, in web.xml, *.do/** but tomcat said invalid url-pattern. If I manage to get ** wilcard mapping work with *.do, I will be able to correctly process a request like http://localhost:8080/myapp/server.do/chapter1/1.html Also, I've tried *.do** , tomcat did accept this but this time, it expected me to write ** at the end of all URL's. That is, it didn't work as a wildcard mapping. And in struts-config.xml, I modified my action as action path=/server** ... but this didn't work either. It seems that ** wildcard mapping is not possible with *.do suffix mapping. What do you think Laurie? -- Forwarded message -- From: Laurie Harper [EMAIL PROTECTED] To: user@struts.apache.org Date: Mon, 26 Sep 2005 14:31:10 -0400 Subject: Re: user Digest 25 Sep 2005 21:39:29 - Issue 6130 emre akbas wrote: Now, I have another problem. We have written our Struts application using prefix mappings, i.e *.do. In order to use DownloadAction with ** mapping, we should migrate to suffix mapping, i.e. /do/* . Is there an easy way of migrating a whole Struts application from prefix mapping to suffix mapping? Or, is it possible that both mappings exists in web.xml ? (Sorry, if these are weird questions.) [Note: '*.do' is a suffix, /do/* is a prefix (pre- - previous); just to reduce any confusion for people following along ;-)] Actually, I think wildcard mappings *should* work with suffix mapping too, though I've never tried it. But you can define both types of mapping in web.xml, so long as you pick a prefix your application doesn't already use. In other words, as long as you don't already have linkes that start /do/... then adding a /do/* mapping is fine. Migrating your whole app from one mapping style to the other wouldn't be super hard -- just find anywhere you have an explicit .do and update appropriately. However, I wouldn't recommend trying that if this is the only driver. If what you have works, keep it ;-) L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Re: i18n and l10n issue - need help
Thanks a lot Laurie. I have the ApplicationResources_zh.properties in WEB-INF/classes along with other locale property files. The issue is, always I am seeing the default locale, even when I am explicitly changing the browser locale setting to Chinese. The things I did are, I created the ApplicationResources_zh.properties in MS-WORD with UTF-8 encoding (in text editors we could not enter the special language characters) Coded the jsp with response.setContentType(text/html;charset=UTF-8). Restarted the server and see the above behaviour. I doubt, my way of creating the property file is wrong. Please advice. -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper Sent: Tuesday, September 27, 2005 1.54 PM To: user@struts.apache.org Subject: Re: i18n and l10n issue - need help Balasubramaniam, Sezhiyan wrote: We were giving locale support for English, Spanish, French and German in one of our STRUTS 1.0.1 intranet application. So far, it went smooth as all the resource bundles are ASCII based. Recently we got some requirements on double byte characters (CHINESE and JAPANESE) Even after we added the ApplicationResources_zh.properties and ApplicationResources_ja.properties into the classpath, STRUTS is not picking up the messages. As we are new to this i18n and l10n, we don't have much clue. Are we missing some thing? Is there any set-up needed for supporting the special languages. No, it should work the same way as it does for any other language. What behaviour are you seeing? Do you get missing messages, or messages from one of the other resource bundles? Is your ApplicationResources_zh.properties in the same place your other properties files are? And how are you selecting the locale to use? On the other side I was reading the STRUTS site and it says, Please note that the i18n support in a framework like Struts is limited to the presentation of internationalized text and images to the user. Support for Locale specific input methods (used with languages such as Japanese, Chinese, and Korean) is left up to the client device, which is usually a web browser. This doesn't effect the rendering of messages, just how the user enters text into forms and so on. In other words, that's talking about how the user enters data into your application, not how your application dispalys data to the user. L. - 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: ActionMessage and bundle choice
emre akbas wrote: Hi, We know that ActionMessage class has a field to store the key of the message but not the bundle name of the key. For (error) messages that are not in the default message-resources, we can do the trick in the jsp file by giving the bundle of the key like: html:messages bundle=core id=msg bean:write name=msg/ /html:messages So far so good. But, what we shall do if the ActionMessages contain messages which have to be resolved from different bundles? Should we write several html:messages tags with different bundles? That would appear to be the only option; ActionMessages doesn't have a way to specify the bundle. That might be a useful enhancement, though. L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to reference pages external to a webapp using Tiles
Ekberg Mats KONSULT wrote: I am working on an export coltrol system for the swedish customs. We are using struts and the tiles framework. We would like to have a separate webapp (or even a plain html site) with some standard templates for mainly menus. I have placed some images and standardized jsp-files there, these files should be used for all webapps developed. The problem is when I try to reference those jsp-pages in my tiles definitions file as absolute urls, Cannot get request dispatcher for path http://localhost:7001/std/tiles/common/layout.jsp. The referencing webapp is at http://localhost:7001/ex/do/... And the def looks like: definition name=.layout.ecs path=http://localhost:7001/std/tiles/common/layout.jsp; Is there a solution to this or must the standardized pages included in each webapp? If you're using Tomcat, you *might* be able to get this to work by setting crossContext to true in the Context configuration [1]. I'm not sure how 'supported' this usage would be though, and I have no idea how you would do the same thing for any other servlet container. L. [1] http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/context.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JSF or Struts Classic (was Vs)
There is a fundamental problem with talking about the definition of words in other than a lexical sense. Words do not have definitions like you find, for example, in biology but, rather, have meanings and the meaning is, as Ludwig Wittgenstein loved to say, the use. People who look for and talk too much about definitions of terms tend to have idiosyncratic and private senses of terms which leads to confusion rather than to clarification, to heat rather than to light. Words are neither swords nor shields in life and its battles, but are a mysterious and wonderful public way to communicate within the dimensions of our environments and understanding. Hence, there is not a right or wrong way to talk about components, but there is the way they are talked about and if you don't to do it that way, then no one will understand you. I like the way Ted tackled this issue. The issue never had anything to do with meanings, definitions or the word component. Thanks, Ted. On 9/26/05, Ted Husted [EMAIL PROTECTED] wrote: On 9/22/05, Michael Oliver [EMAIL PROTECTED] wrote: If you are going to compose an application from components, then the components are more closely aligned with the business objects they encapsulate. A Customer component then may be composed into any number of Applications from Accounts Payable to CRM. Such a Component would have its own UI for CRUD operations, and a Web Services Interface for data and method access, and it would likely have its own data persistence or utilize framework or container managed persistence. In our application, now that we are collecting coherent segments of ASPX code into controls, that's what exactly what is happening. The architecture is chain-based and service-orientated. We aren't using business objects per se, but there are a number of business entities present in the model (database schema). The command and query files for Chain and iBATIS are grouped by business entity. The iBATIS datamaps acts like a code-behind for the Commands. For every coherent set of command, we end up with a companion datamap configuration. The ASPX page flows tend to follow entity lines as well, which became even more apparent when we started normalizing the UI into controls. Now we have a components like a FacilityFinder, FacilityLister, FacilityViewer, and FacilityEdtior, each of which is encapsulated as a tag (or component) with it's own markup and code-behind. The neat part is that its easy to reuse these components when use cases cross entity lines. If we need to list or edit facilities as part of a larger case, we can plop the appropriate tag on the page, turning it on and off as needed. The ASPX page then starts to act like a controller. Instead of presenting content, it manages a set of components from its own code-behind. Right now, most of our pages look like this: %@ Page language=c# Codebehind=Events.aspx.cs AutoEventWireup=false Inherits=WQD.Web.Forms.Events % %@ Register TagPrefix=spring Namespace=Spring.Web.UI.Controls Assembly=Spring.Web % %@ Register TagPrefix=wqd TagName=Lister Src=../Controls/StepLister.ascx % %@ Register TagPrefix=wqd TagName=Finder Src=../Controls/StepFinder.ascx % !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN HTML body spring:Content contentPlaceholderId=cphMain id=cphMainContent runat=server wqd:Lister id=lister runat=server/wqd:Lister wqd:Finder id=finder Runat=server/wqd:Finder /spring:Content /body (The content tags are part of the Spring templating system, which is not unlike Tiles.) This page presents a finder control and a lister control. The finder control collects search criteria. The code-behind hands the critieria it collects to the lister using a method like this: protected void finder_Click(object sender, EventArgs e) { AppArgs a = e as AppArgs; lister.Open(a.Criteria); // A Criteria is a Map lister.Visible = true; Template_Load(App.msg_EVENTS_HEADING, App.msg_EVENTS_LIST_PROMPT); } After browsing the list, the client might select an item protected void lister_Click(object sender, EventArgs e) { AppArgs a = e as AppArgs; Key = a.facility_issue_key; SetResult(App.RESULT_STEP_LIST); } SetResult is a Spring.Web base method. It fires a redirect or forward to another page. We coded the result so that the Key property is included. The reference is kept in a configuration file. This ResultSet elements tells Spring.Web to redirect to the Search.aspx page and append the query string op=Issuesq=${Key}, where Key is a property on the calling page. (Obviously, the value of Key replaces the variable notation.) object id=StepList type=Spring.Web.Support.Result, Spring.Web property name=TargetPagevalueSearch.aspx/value/property property
Re: writing images from a database
I went through the process recently - the performance of MySQL handling images was soo bad I immediately changed all my thinking and put the images in a sub-directory in my file system. The code I was using was buffering (32k) and the images were only about 100k and still I had to wait 8 seconds for them to appear on my browser - simply not accepable. The same images in the file system appeared near-instantaneously on my browser. Also, MySQL had a default buffer size limit of 1mb, any file I uploaded needed to be within this limit. I know I can modify this, but what do I modify it to? Should I make it 2mb, 10mb, 100mb, 2gb, 4gb, how big is my upload file going to be? It was all very restrictive and badly implemented. Maybe oracle is better? Kind regards mc On 27 Sep 2005 at 9:47, Dakota Jack wrote: You need to put in a bit more buffering, etc. in this code, Mark. I recommend you read up on how to read and to write to files more efficiently. Also, due to the nature of how computers work, I would highly recommend you create a multi-threaded application to do this. You will find that your performance will be hugely impacted. On 9/27/05, Mark Benussi [EMAIL PROTECTED] wrote: I've seen this conversation before so I don't think I am saying anything outlandish here. There is a performance overhead from reading a database to present to the JSP page, however you look at it. There is nothing wrong with writing the image once to the file system, and storing a reference to the image on the file system. -Original Message- From: Braun, James F [mailto:[EMAIL PROTECTED] Sent: 27 September 2005 17:24 To: Struts Users Mailing List Subject: writing images from a database Goal: Read a blob image from an Oracle database and render it on an html page using the struts framework. I've never found a good way to do this and I was hoping someone had a best practice suggestion. I have no trouble getting the image from the database. However, I wonder if there isn't a better way to display it rather than writing it to a physical file and then rendering it. I'm using the html:img tag to display the image now. All help appreciated. J. ImputStream pictureStream; ResultSet rs; // create the query and execute it ... // get the result pictureStream = rs.getBinaryStream(picture); // I can write it to a physical file File pictureFile = new File(/temp/picture.jpg); try { FileOutputStream out = new FileOutputStream(pictureFile); int chunk = 0; while( (chunk = pictureStream.read()) != -1) { out.write(chunk); } out.close(); out.flush(); } catch(FileNotFoundException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } catch(IOException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } -- This transmission is intended only for use by the addressee(s) named herein and may contain information that is proprietary, confidential and/or legally privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. - 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] -- You can lead a horse to water but you cannot make it float on its back. ~Dakota Jack~ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.7/112 - Release Date: 26/09/2005 FOCUS Computing Mob: 0415 24 26 24 [EMAIL PROTECTED] http://www.focus-computing.com.au -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.7/112 - Release Date: 26/09/2005 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands,
Re: Re: i18n and l10n issue - need help
On 9/27/05, Balasubramaniam, Sezhiyan [EMAIL PROTECTED] wrote: Thanks a lot Laurie. I have the ApplicationResources_zh.properties in WEB-INF/classes along with other locale property files. The issue is, always I am seeing the default locale, even when I am explicitly changing the browser locale setting to Chinese. The things I did are, I created the ApplicationResources_zh.properties in MS-WORD with UTF-8 encoding (in text editors we could not enter the special language characters) Coded the jsp with response.setContentType(text/html;charset=UTF-8). Restarted the server and see the above behaviour. I doubt, my way of creating the property file is wrong. Please advice. See Struts MailReader Demonstration Application. In short: 1) Use plain 8-bit ASCII (or whatever western encoding it is) for ApplicationResources_zh.properties. 2) Encode all Unicode stuff with Unicode escapes like this is Russian for Cancel: button.cancel=\u041e\u0442\u043c\u0435\u043d\u0438\u0442\u044c 3) For Struts to pick up your localized properties you have to set locale in the session: locale = new Locale(language, ); session.setAttribute(Globals.LOCALE_KEY, locale); 4) This one is ok: Coded the jsp with response.setContentType(text/html;charset=UTF-8) But it is easier to set it right in the JSP: %@ page contentType=text/html;charset=UTF-8 language=java % 5) Make sure that this setting in struts-config.xml points to proper file: !-- Resources in WEB-INF/classes/ApplicationResources.properties -- message-resources parameter=ApplicationResources null=false/ If your resource file is in different directory, change parameter accordingly. Michael. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: dir Attribute in HTML Tag library
From: Laurie Harper [EMAIL PROTECTED] Sent: Tuesday, September 27, 2005 10:18 PM yogi wrote: Hi All, This is regarding dir attribute is Struts HTML tag library. The HTML taglib contains tags used to create Struts input forms, as well as other tags generally useful in the creation of HTML-based user interfaces. The output is HTML 4.01 compliant or XHTML 1.0 when in XHTML mode. According to HTML 4.0 specification HTML element has following attribute -- --- !ENTITY % html.content HEAD, BODY !ELEMENT HTML O O ( %html.content;)-- document root element -- !ATTLIST HTML %i18n; -- lang, dir -- -- - And struts HTML tag takes following attributes -- --- 1. lang 2. locale 3. xhtml - -- THEN HOW I CAN SPECIFY DIR ATTRIBUTE IN STRUTS? Is there any way I can specify this?Please let me know Thanks in Advance -Yogesh Unfortunately the 'html' tag doesn't currently support the 'dir' attribute. It would be easy to add, though. I'd suggest posting an enhancement request to Bugzilla. L. There is already an enhancement request for this, no patch though :-( http://issues.apache.org/bugzilla/show_bug.cgi?id=21171 Niall - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: i18n and l10n issue - need help
Balasubramaniam, Sezhiyan wrote: Thanks a lot Laurie. I have the ApplicationResources_zh.properties in WEB-INF/classes along with other locale property files. The issue is, always I am seeing the default locale, even when I am explicitly changing the browser locale setting to Chinese. The things I did are, I created the ApplicationResources_zh.properties in MS-WORD with UTF-8 encoding (in text editors we could not enter the special language characters) That wont work properly; Java requires properties files to be in ASCII (or maybe Latin-1?). Use the native2ascii utility bundled with the JDK to convert your UTF-8 encoded file to the correct format. Coded the jsp with response.setContentType(text/html;charset=UTF-8). Restarted the server and see the above behaviour. Is it possible the browser isn't sending the right headers to select language 'zh'? Try setting the locale explicitly in your JSP and see if you can get the right messages that way (that'll confirm Struts is loading the messages correctly). If you can get that working, you can look into why the locale isn't being auto-detected correctly. L. I doubt, my way of creating the property file is wrong. Please advice. -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper Sent: Tuesday, September 27, 2005 1.54 PM To: user@struts.apache.org Subject: Re: i18n and l10n issue - need help Balasubramaniam, Sezhiyan wrote: We were giving locale support for English, Spanish, French and German in one of our STRUTS 1.0.1 intranet application. So far, it went smooth as all the resource bundles are ASCII based. Recently we got some requirements on double byte characters (CHINESE and JAPANESE) Even after we added the ApplicationResources_zh.properties and ApplicationResources_ja.properties into the classpath, STRUTS is not picking up the messages. As we are new to this i18n and l10n, we don't have much clue. Are we missing some thing? Is there any set-up needed for supporting the special languages. No, it should work the same way as it does for any other language. What behaviour are you seeing? Do you get missing messages, or messages from one of the other resource bundles? Is your ApplicationResources_zh.properties in the same place your other properties files are? And how are you selecting the locale to use? On the other side I was reading the STRUTS site and it says, Please note that the i18n support in a framework like Struts is limited to the presentation of internationalized text and images to the user. Support for Locale specific input methods (used with languages such as Japanese, Chinese, and Korean) is left up to the client device, which is usually a web browser. This doesn't effect the rendering of messages, just how the user enters text into forms and so on. In other words, that's talking about how the user enters data into your application, not how your application dispalys data to the user. L. - 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: writing images from a database
Thanks Murray. Jack you missed my point, it was nothing to do with the expense of file writing etc but with the hit of obtaining a database connection and writing the bytes to file (In whatever highly efficient method you recommend) -Original Message- From: Murray Collingwood [mailto:[EMAIL PROTECTED] Sent: 27 September 2005 22:46 To: user@struts.apache.org Subject: Re: writing images from a database I went through the process recently - the performance of MySQL handling images was soo bad I immediately changed all my thinking and put the images in a sub-directory in my file system. The code I was using was buffering (32k) and the images were only about 100k and still I had to wait 8 seconds for them to appear on my browser - simply not accepable. The same images in the file system appeared near-instantaneously on my browser. Also, MySQL had a default buffer size limit of 1mb, any file I uploaded needed to be within this limit. I know I can modify this, but what do I modify it to? Should I make it 2mb, 10mb, 100mb, 2gb, 4gb, how big is my upload file going to be? It was all very restrictive and badly implemented. Maybe oracle is better? Kind regards mc On 27 Sep 2005 at 9:47, Dakota Jack wrote: You need to put in a bit more buffering, etc. in this code, Mark. I recommend you read up on how to read and to write to files more efficiently. Also, due to the nature of how computers work, I would highly recommend you create a multi-threaded application to do this. You will find that your performance will be hugely impacted. On 9/27/05, Mark Benussi [EMAIL PROTECTED] wrote: I've seen this conversation before so I don't think I am saying anything outlandish here. There is a performance overhead from reading a database to present to the JSP page, however you look at it. There is nothing wrong with writing the image once to the file system, and storing a reference to the image on the file system. -Original Message- From: Braun, James F [mailto:[EMAIL PROTECTED] Sent: 27 September 2005 17:24 To: Struts Users Mailing List Subject: writing images from a database Goal: Read a blob image from an Oracle database and render it on an html page using the struts framework. I've never found a good way to do this and I was hoping someone had a best practice suggestion. I have no trouble getting the image from the database. However, I wonder if there isn't a better way to display it rather than writing it to a physical file and then rendering it. I'm using the html:img tag to display the image now. All help appreciated. J. ImputStream pictureStream; ResultSet rs; // create the query and execute it ... // get the result pictureStream = rs.getBinaryStream(picture); // I can write it to a physical file File pictureFile = new File(/temp/picture.jpg); try { FileOutputStream out = new FileOutputStream(pictureFile); int chunk = 0; while( (chunk = pictureStream.read()) != -1) { out.write(chunk); } out.close(); out.flush(); } catch(FileNotFoundException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } catch(IOException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } -- This transmission is intended only for use by the addressee(s) named herein and may contain information that is proprietary, confidential and/or legally privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. - 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] -- You can lead a horse to water but you cannot make it float on its back. ~Dakota Jack~ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.7/112 -
Re: ActionMessage and bundle choice
From: Laurie Harper [EMAIL PROTECTED] Sent: Tuesday, September 27, 2005 10:34 PM emre akbas wrote: Hi, We know that ActionMessage class has a field to store the key of the message but not the bundle name of the key. For (error) messages that are not in the default message-resources, we can do the trick in the jsp file by giving the bundle of the key like: html:messages bundle=core id=msg bean:write name=msg/ /html:messages So far so good. But, what we shall do if the ActionMessages contain messages which have to be resolved from different bundles? Should we write several html:messages tags with different bundles? That would appear to be the only option; ActionMessages doesn't have a way to specify the bundle. That might be a useful enhancement, though. L. There appears to be a couple of enhancement request for this: http://issues.apache.org/bugzilla/show_bug.cgi?id=7892 http://issues.apache.org/bugzilla/show_bug.cgi?id=30401 Niall - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Nested Dynavalidator forms
You wouldn't be able to in one form-bean declaration, but you could do several then combine them in your Action. form-bean name=childForm type=...DynaValidatorForm form-property name=value type=java.lang.String/ /form-bean form-bean name=parentForm type=...DynaValidatorForm form-property name=child type=...DynaValidatorForm/ /form-bean In your pre-population action: DynaValidatorForm childForm = childFormBeanConfig.createActionForm(getServlet()); parentForm.set(child, childForm); // use session scope so the child form is available upon form submission session.setAttribute(parentForm, parentForm); In your jsp: html:text property=child.value/ Hubert On 9/27/05, Laurie Harper [EMAIL PROTECTED] wrote: raghu wrote: How do we build dynavalidator forms that have as one of their fields another dynavalidator form? My first thought was form-bean name=xxx type=...DynaValidatorForm form-property name=nested type=...DynaValidatorForm/ but of course you can't configure the nested dyna form that way. Maybe lazy dyna forms would work here? L. - 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]
e-mail address validator
I'm looking for a regular expression or something I can plug into Struts 1.2 to validate e-mail addresses off of a DynaForms. Anyone have any pointers? Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[ANN] Informecial: how Struts Dialogs changes the way you write Struts apps
I hope that this short intro to Struts Dialogs is informative enough not to be considered as just an advertisement. It tries to explain the main concepts that Struts Dialogs is based on: * tighter integration of JSP markup with Java action * event handling, based on DispatchAction * two-phase request processing http://jroller.com/page/javadujour?entry=code_behind_for_struts Enjoy. The article has pictures :-) Comments are welcome. Michael J. -- Struts Dialogs http://struts.sourceforge.net/strutsdialogs - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: dir Attribute in HTML Tag library
Niall Pemberton wrote: There is already an enhancement request for this, no patch though :-( http://issues.apache.org/bugzilla/show_bug.cgi?id=21171 The discussion on the linked bug is rather entertaining reading though ;-) L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: dir Attribute in HTML Tag library
On 9/27/05, Laurie Harper [EMAIL PROTECTED] wrote: Niall Pemberton wrote: There is already an enhancement request for this, no patch though :-( http://issues.apache.org/bugzilla/show_bug.cgi?id=21171 The discussion on the linked bug is rather entertaining reading though ;-) Indeed. Two years, solutione exists, works, but is not accepted by the Party. Martin Cooper, 2005-06-17: It does have to do with the HTML 4.01 spec. With such a change, we allow the Struts tags to generate HTML that is not compliant with that spec. For *years* we have said that the Struts tags will generate valid HTML 4.01 code, and I, for one, am not willing to see us go back on that decision now. Whoa! Being a bit stalinistic, are we? What happened to freedom of choice? So un-American ;-) Craig McClanahan, 2005-06-21: As for adding something like html:attribute, I think it is definitely bad policy to hand developers a loaded gun aimed at their feet. They already have boxes full of TNT on their desks. Letting them have a gun as well does not change a lot. Really, imagine a battle tank with a gun which cannot be rotated backwards: We do not want them to fire at our own troops. Tank commanders are not idiots (en masse), so are programmers. I never took the best thing since sliced bread seriously, but seems that there are quite a few of Darwin Law victims, who can cut themselves with a kitchen knife and then bleed to death. Anyway, Struts task is not childproofing the house, but is to provide aid in web development, is not it? Michael J. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: writing images from a database
Okay. Your point was you don't know how to write a response? Okay. I will let the others know that we were wrong that you wanted to do this right. On 9/27/05, Mark Benussi [EMAIL PROTECTED] wrote: Thanks Murray. Jack you missed my point, it was nothing to do with the expense of file writing etc but with the hit of obtaining a database connection and writing the bytes to file (In whatever highly efficient method you recommend) -Original Message- From: Murray Collingwood [mailto:[EMAIL PROTECTED] Sent: 27 September 2005 22:46 To: user@struts.apache.org Subject: Re: writing images from a database I went through the process recently - the performance of MySQL handling images was soo bad I immediately changed all my thinking and put the images in a sub-directory in my file system. The code I was using was buffering (32k) and the images were only about 100k and still I had to wait 8 seconds for them to appear on my browser - simply not accepable. The same images in the file system appeared near-instantaneously on my browser. Also, MySQL had a default buffer size limit of 1mb, any file I uploaded needed to be within this limit. I know I can modify this, but what do I modify it to? Should I make it 2mb, 10mb, 100mb, 2gb, 4gb, how big is my upload file going to be? It was all very restrictive and badly implemented. Maybe oracle is better? Kind regards mc On 27 Sep 2005 at 9:47, Dakota Jack wrote: You need to put in a bit more buffering, etc. in this code, Mark. I recommend you read up on how to read and to write to files more efficiently. Also, due to the nature of how computers work, I would highly recommend you create a multi-threaded application to do this. You will find that your performance will be hugely impacted. On 9/27/05, Mark Benussi [EMAIL PROTECTED] wrote: I've seen this conversation before so I don't think I am saying anything outlandish here. There is a performance overhead from reading a database to present to the JSP page, however you look at it. There is nothing wrong with writing the image once to the file system, and storing a reference to the image on the file system. -Original Message- From: Braun, James F [mailto:[EMAIL PROTECTED] Sent: 27 September 2005 17:24 To: Struts Users Mailing List Subject: writing images from a database Goal: Read a blob image from an Oracle database and render it on an html page using the struts framework. I've never found a good way to do this and I was hoping someone had a best practice suggestion. I have no trouble getting the image from the database. However, I wonder if there isn't a better way to display it rather than writing it to a physical file and then rendering it. I'm using the html:img tag to display the image now. All help appreciated. J. ImputStream pictureStream; ResultSet rs; // create the query and execute it ... // get the result pictureStream = rs.getBinaryStream(picture); // I can write it to a physical file File pictureFile = new File(/temp/picture.jpg); try { FileOutputStream out = new FileOutputStream(pictureFile); int chunk = 0; while( (chunk = pictureStream.read()) != -1) { out.write(chunk); } out.close(); out.flush(); } catch(FileNotFoundException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } catch(IOException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } -- This transmission is intended only for use by the addressee(s) named herein and may contain information that is proprietary, confidential and/or legally privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. - 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] -- You can lead a horse to water but you cannot make it float on
Re: e-mail address validator
I'm looking for a regular expression or something I can plug into Struts 1.2 to validate e-mail addresses off of a DynaForms. Anyone have any pointers? Never mind. I found this one on an ASP.Net page: [EMAIL PROTECTED],3} it is good enough for my needs. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: writing images from a database
Sorry, Ross, he doesn't care about doing this well. Only just doing it somehow. On 9/27/05, Ross Gibb [EMAIL PROTECTED] wrote: I'm using DB2 with pictures stored as blobs. We have a system similar to what Wendy suggested. When the image is retrieved from the database it is sent to an image servlet that will cache the image. The browser then asks the image servlet for the image. The image servlet is also smart enough to ask the database for the image if it finds it is not available in the cache. I tried to write it flexibly enough so that the size of the image cache and the the amount of time an image stays in cache is flexible. Also, if this system becomes too slow we should easily be able to switch to a file system approach. Good luck, Ross Braun, James F wrote: Goal: Read a blob image from an Oracle database and render it on an html page using the struts framework. I've never found a good way to do this and I was hoping someone had a best practice suggestion. I have no trouble getting the image from the database. However, I wonder if there isn't a better way to display it rather than writing it to a physical file and then rendering it. I'm using the html:img tag to display the image now. All help appreciated. J. ImputStream pictureStream; ResultSet rs; // create the query and execute it ... // get the result pictureStream = rs.getBinaryStream(picture); // I can write it to a physical file File pictureFile = new File(/temp/picture.jpg); try { FileOutputStream out = new FileOutputStream(pictureFile); int chunk = 0; while( (chunk = pictureStream.read()) != -1) { out.write(chunk); } out.close(); out.flush(); } catch(FileNotFoundException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } catch(IOException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- You can lead a horse to water but you cannot make it float on its back. ~Dakota Jack~ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: writing images from a database
Sorry, Murray, he just wants to do it. All the performance, etc. stuff is just not relevant to his coding. On 9/27/05, Murray Collingwood [EMAIL PROTECTED] wrote: I went through the process recently - the performance of MySQL handling images was soo bad I immediately changed all my thinking and put the images in a sub-directory in my file system. The code I was using was buffering (32k) and the images were only about 100k and still I had to wait 8 seconds for them to appear on my browser - simply not accepable. The same images in the file system appeared near-instantaneously on my browser. Also, MySQL had a default buffer size limit of 1mb, any file I uploaded needed to be within this limit. I know I can modify this, but what do I modify it to? Should I make it 2mb, 10mb, 100mb, 2gb, 4gb, how big is my upload file going to be? It was all very restrictive and badly implemented. Maybe oracle is better? Kind regards mc On 27 Sep 2005 at 9:47, Dakota Jack wrote: You need to put in a bit more buffering, etc. in this code, Mark. I recommend you read up on how to read and to write to files more efficiently. Also, due to the nature of how computers work, I would highly recommend you create a multi-threaded application to do this. You will find that your performance will be hugely impacted. On 9/27/05, Mark Benussi [EMAIL PROTECTED] wrote: I've seen this conversation before so I don't think I am saying anything outlandish here. There is a performance overhead from reading a database to present to the JSP page, however you look at it. There is nothing wrong with writing the image once to the file system, and storing a reference to the image on the file system. -Original Message- From: Braun, James F [mailto:[EMAIL PROTECTED] Sent: 27 September 2005 17:24 To: Struts Users Mailing List Subject: writing images from a database Goal: Read a blob image from an Oracle database and render it on an html page using the struts framework. I've never found a good way to do this and I was hoping someone had a best practice suggestion. I have no trouble getting the image from the database. However, I wonder if there isn't a better way to display it rather than writing it to a physical file and then rendering it. I'm using the html:img tag to display the image now. All help appreciated. J. ImputStream pictureStream; ResultSet rs; // create the query and execute it ... // get the result pictureStream = rs.getBinaryStream(picture); // I can write it to a physical file File pictureFile = new File(/temp/picture.jpg); try { FileOutputStream out = new FileOutputStream(pictureFile); int chunk = 0; while( (chunk = pictureStream.read()) != -1) { out.write(chunk); } out.close(); out.flush(); } catch(FileNotFoundException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } catch(IOException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } -- This transmission is intended only for use by the addressee(s) named herein and may contain information that is proprietary, confidential and/or legally privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. - 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] -- You can lead a horse to water but you cannot make it float on its back. ~Dakota Jack~ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.7/112 - Release Date: 26/09/2005 FOCUS Computing Mob: 0415 24 26 24 [EMAIL PROTECTED]
Re: writing images from a database
He doesn't care about overhead, Frank. He just wants to do it. If it is slow, ugly, etc. that does not matter to him. On 9/27/05, Frank W. Zammetti [EMAIL PROTECTED] wrote: The Wiki is your friend: http://wiki.apache.org/struts/StrutsFileDownload Specifically, you will be interested in the downloadapp.zip sample I posted there... it has an example of serving a BLOB from a database. All you need to do is have a mapping to this Action, and use it as the src attribute of an img tag. As another poster said though, there is definitely a fair amount of overhead to doing this. That being said, I've done it to good effect on at least two occassions. But, you do have to think about whether it is appropriate... in my case, it was a client's logo in a frame that only changed when the user changed clients, very infrequent. I can't imagine I'd serve images from a database if it was going to be needed a lot... I'd have to have an exceptionally good reason for doing it. Maybe you do :) In any case, that sample app should show you how. Note too that even if you aren't using a version of Struts with the DownloadAction, what's there is still somewhat applicable, and there's nothing to stop you from bringing DownloadAction over to your app anyway AFAIK. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com On Tue, September 27, 2005 12:23 pm, Braun, James F said: Goal: Read a blob image from an Oracle database and render it on an html page using the struts framework. I've never found a good way to do this and I was hoping someone had a best practice suggestion. I have no trouble getting the image from the database. However, I wonder if there isn't a better way to display it rather than writing it to a physical file and then rendering it. I'm using the html:img tag to display the image now. All help appreciated. J. ImputStream pictureStream; ResultSet rs; // create the query and execute it ... // get the result pictureStream = rs.getBinaryStream(picture); // I can write it to a physical file File pictureFile = new File(/temp/picture.jpg); try { FileOutputStream out = new FileOutputStream(pictureFile); int chunk = 0; while( (chunk = pictureStream.read()) != -1) { out.write(chunk); } out.close(); out.flush(); } catch(FileNotFoundException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } catch(IOException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } -- This transmission is intended only for use by the addressee(s) named herein and may contain information that is proprietary, confidential and/or legally privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. - 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] -- You can lead a horse to water but you cannot make it float on its back. ~Dakota Jack~ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: writing images from a database
Oh, wait! I did not miss your point. In fact, I did not even read your point really. Sorry, eveyone. Never mind. On 9/27/05, Mark Benussi [EMAIL PROTECTED] wrote: Thanks Murray. Jack you missed my point, it was nothing to do with the expense of file writing etc but with the hit of obtaining a database connection and writing the bytes to file (In whatever highly efficient method you recommend) -Original Message- From: Murray Collingwood [mailto:[EMAIL PROTECTED] Sent: 27 September 2005 22:46 To: user@struts.apache.org Subject: Re: writing images from a database I went through the process recently - the performance of MySQL handling images was soo bad I immediately changed all my thinking and put the images in a sub-directory in my file system. The code I was using was buffering (32k) and the images were only about 100k and still I had to wait 8 seconds for them to appear on my browser - simply not accepable. The same images in the file system appeared near-instantaneously on my browser. Also, MySQL had a default buffer size limit of 1mb, any file I uploaded needed to be within this limit. I know I can modify this, but what do I modify it to? Should I make it 2mb, 10mb, 100mb, 2gb, 4gb, how big is my upload file going to be? It was all very restrictive and badly implemented. Maybe oracle is better? Kind regards mc On 27 Sep 2005 at 9:47, Dakota Jack wrote: You need to put in a bit more buffering, etc. in this code, Mark. I recommend you read up on how to read and to write to files more efficiently. Also, due to the nature of how computers work, I would highly recommend you create a multi-threaded application to do this. You will find that your performance will be hugely impacted. On 9/27/05, Mark Benussi [EMAIL PROTECTED] wrote: I've seen this conversation before so I don't think I am saying anything outlandish here. There is a performance overhead from reading a database to present to the JSP page, however you look at it. There is nothing wrong with writing the image once to the file system, and storing a reference to the image on the file system. -Original Message- From: Braun, James F [mailto:[EMAIL PROTECTED] Sent: 27 September 2005 17:24 To: Struts Users Mailing List Subject: writing images from a database Goal: Read a blob image from an Oracle database and render it on an html page using the struts framework. I've never found a good way to do this and I was hoping someone had a best practice suggestion. I have no trouble getting the image from the database. However, I wonder if there isn't a better way to display it rather than writing it to a physical file and then rendering it. I'm using the html:img tag to display the image now. All help appreciated. J. ImputStream pictureStream; ResultSet rs; // create the query and execute it ... // get the result pictureStream = rs.getBinaryStream(picture); // I can write it to a physical file File pictureFile = new File(/temp/picture.jpg); try { FileOutputStream out = new FileOutputStream(pictureFile); int chunk = 0; while( (chunk = pictureStream.read()) != -1) { out.write(chunk); } out.close(); out.flush(); } catch(FileNotFoundException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } catch(IOException ex) { System.err.println(selectionForm.populate.picturefile: + ex.getMessage()); logger.error(selectionForm.populate.picturefile: + ex.getMessage()); } -- This transmission is intended only for use by the addressee(s) named herein and may contain information that is proprietary, confidential and/or legally privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. - 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] -- You can lead a horse to water but you cannot make it float on its back. ~Dakota Jack~