[HELP] I use struts + Velocity, I couldn't submit 1 form with unicode information! :(
Hi all, I use Struts framework + Velocity, and I have a form with a text field, something like below: form method=POST action=$link.setAction(/saveIt) table tr td input type=text name=something /td /tr /table /form in velocity.properties file, I set: input.encoding=UTF-8 output.encoding=UTF-8 hiz, but with all above, I couldn't save unicode value of something property into my DB (Mysql 4.1, I had set all utf-8) :( but ... when I change the header of form tag like below, everything is fine, it's mean, I can save unicode value into DB :( ... I don't know why, help me plz :( form enctype=multipart/form-data method=POST action=$link.setAction(/saveIt) thanks in advance, bowlkhin
Struts Velocity
Hi all, Im just trying to get my head around this. Struts is meant to work with actions. You create the mappings of the actions in the struts-config.xml and define things like action handlers, forwards, etc. Suppose I use Velocity to render the view. Is there a standar place in struts or anywhere else that I can populate the velocity context? (Doing it through request.put() of course) My problem comes when I need to change the Locale for a page which fires up a LocaleAction class which then renders the page Ive specified *but* without the velocity context being populated since all the logic to populate the context is defined in a different class. In Turbine for example there is method which gets called and serves for populating the context. Thanks for your input. Markos Charatzas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts Velocity
On Tuesday 08 February 2005 21:19, Markos Charatzas wrote: Hi all, Im just trying to get my head around this. Struts is meant to work with actions. You create the mappings of the actions in the struts-config.xml and define things like action handlers, forwards, etc. Suppose I use Velocity to render the view. Is there a standar place in struts or anywhere else that I can populate the velocity context? (Doing it through request.put() of course) The easy way is to use the Velocity Servlet in velocity tools. By mapping say any vm file to the servlet you can process vm files. And yes, putting the data in the request or the session will make it available to the view. There isn't anywhere else really. My problem comes when I need to change the Locale for a page which fires up a LocaleAction class which then renders the page Ive specified *but* without the velocity context being populated since all the logic to populate the context is defined in a different class. Not sure I understand - populating the Velocity context is done by the VelocityServlet (of various flavours) from the request attributes and session attributes. Therefore all you actions must have occured prior to handing off to the view. The exception is where method calls are made directly from the Velocity I suppose. Perhaps I'm dumb - but why is an action - the LocaleAction rendering anything? Shouldn't that be the job of Velocity? In Turbine for example there is method which gets called and serves for populating the context. Thanks for your input. Markos Charatzas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Peter Harrison Managing Director Nothing But Net Limited - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts Velocity
Thanks for your input! The easy way is to use the Velocity Servlet in velocity tools. By mapping say any vm file to the servlet you can process vm files. And yes, putting the data in the request or the session will make it available to the view. There isn't anywhere else really. Yeah thats what im doing :D The exception is where method calls are made directly from the Velocity I suppose. Perhaps I'm dumb - but why is an action - the LocaleAction rendering anything? Shouldn't that be the job of Velocity? I didnt put it correct. I dont mean that the LocaleAction renders the page, I mean first calling LocaleAction *and* then rendering the page. So the question is when to call request.put(). At the moment I found a solution by declaring a global forward which always calls the associated action with a given page (passed as a parameter) which handles the request.put in the execute method. However, Im not 100% sure its the right way since I would imagine an Action class would only handle all the business logic to prepare the objects for request.put and not actually making it. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts Velocity
On Tue, 2005-02-08 at 17:54 +0200, Markos Charatzas wrote: I didnt put it correct. I dont mean that the LocaleAction renders the page, I mean first calling LocaleAction *and* then rendering the page. So the question is when to call request.put(). At the moment I found a solution by declaring a global forward which always calls the associated action with a given page (passed as a parameter) which handles the request.put in the execute method. However, Im not 100% sure its the right way since I would imagine an Action class would only handle all the business logic to prepare the objects for request.put and not actually making it. To be honest I think that this should go into VelocityServlet - or a child of it. I'm not sure this exists yet, but it shouldn't be very difficult. I've seen a few people asking about it - but no code yet. Perhaps we will implement it ourselves actually since we are moving into the Chinese market this year. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts Velocity
just to make sure you guys know, the VelocityServlet is deprecated and should be removed following the release of Velocity 1.5. it's replacement is the VelocityViewServlet in the VelocityTools project. so if you have ideas for improvements or contributions, be sure to make them regarding that servlet. :) On Wed, 09 Feb 2005 12:09:52 +1300, Peter Harrison [EMAIL PROTECTED] wrote: On Tue, 2005-02-08 at 17:54 +0200, Markos Charatzas wrote: I didnt put it correct. I dont mean that the LocaleAction renders the page, I mean first calling LocaleAction *and* then rendering the page. So the question is when to call request.put(). At the moment I found a solution by declaring a global forward which always calls the associated action with a given page (passed as a parameter) which handles the request.put in the execute method. However, Im not 100% sure its the right way since I would imagine an Action class would only handle all the business logic to prepare the objects for request.put and not actually making it. To be honest I think that this should go into VelocityServlet - or a child of it. I'm not sure this exists yet, but it shouldn't be very difficult. I've seen a few people asking about it - but no code yet. Perhaps we will implement it ourselves actually since we are moving into the Chinese market this year. - 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: Struts Velocity
Peter, you are 100% right that it should belong there. Actually the way I see it is that as ActionServlet handles Actions so VelocityViewServlet should handle Views! :) Perhaps we will implement it ourselves actually since we are moving into the Chinese market this year. Well that is why they call it OpenSource I guess :) Nathan, Im aware of VelocityViewServlet and that is what I use :) but its good that you mentioned it to avoid misunderstanding. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts/Velocity integration
Konstantin Priblouda wrote: --- Ted Husted [EMAIL PROTECTED] wrote: Gabriel Sidler wrote: I will put something working together based on these ideas/code this coming weekend (I am tied up with my projects today/tomorrow). I hope this will simplify further discussions. That sounds great, Gabe. I can hack on it tomorrow over weekend . And can share my code with Gabriel ( if he likes :) ) Hallo Konstantin, How is it going? Anywhere I can jump in? Gabe -- Gabriel Sidler Software Engineer, Eivycom GmbH, Zurich, Switzerland -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Struts/Velocity integration
On 12/5/01 6:57 PM, Ted Husted [EMAIL PROTECTED] wrote: Geir Magnusson Jr. wrote: So, how about if we port the Veltag context gizmo to VelServlet, and provide a JavaBean that can return the Struts Action resources when given the current servlet request object. Yep. If you can update the VelServlet with that then, I think I can handle the rest, and update the example application to use the amended getter syntax. So, the plan would be for VelServlet to be a generic way to expose Velocity to a framework that relies on the standard contexts. It would have options for whether or not to chain the context with the request and the session, what context name to use for the getter, and a factory method for inserting the getter into the Velocity context. Think that there shouldn't be either option as request and session should be in there for each and the key should be the same. This prevents portability problems as you can then always be guaranteed that you can mix templates from different apps. It should also also watch for a VelocityContext being passed in the request, and then use that one instead of the blank one that VelServlet would otherwise provide. (The request key name for the VelocityContext being another servlet configuration.) I'll then subclass VelServlet to put a Struts resources getter into the Velocity context. A Velocity template can then get the Struts resources by chanting $getter, where, as far as Velocity is concerned, the getter is simply another JavaBean in the VelocityContext. And don't worry about making it a bean. The interface can be as rich as you want it to be... This should be enough to fulfill the Struts API contracts with the view, and the expectations of everyone concerned, without any changes to the Struts or Velocity cores .. proving once again that Velocity is a full-featured templating tool, designed to work well in any Java application .. even a Struts Web application ;-) If you can continue to host the generic VelServlet in the Velocity distribution, along with VelTag, then I will move toward hosting StrutsVelServlet in the Struts CVS. The problem with this is that there are a huge number of application assumptions built into what you are calling 'VelServlet' that I don't believe should be in the Velocity core. -- Geir Magnusson Jr. [EMAIL PROTECTED] System and Software Consulting Whoever would overthrow the liberty of a nation must begin by subduing the freeness of speech. - Benjamin Franklin -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Struts/Velocity integration
RequestUtils is JSP-centric since it was written to support the tag extensions. Any other apparent bias simply flows from the fact that right now, JSPs is all Struts developers have at their disposal. But the framework itself, is just tossing around JavaBeans and URIs, and things straight out of the Servlet specification. There *is* a Servlet and JavaBean bias, which I doubt would change anytime soon. Meanwhile, If there were methods we could add to RequestUtils that would benefit other presentation systems, then I'd be happy to commit them. I do not consider JSPs to have any special status with the framework, they are just want the initial volunteers were interested in doing. The Struts resources themselves are first-order objects exposed in the application scope, where anyone in the application can use them. I believe that the original VelocityServlet idea is sound, and could expose Velocity to any Web framework that uses the standard Servlet contexts, including Struts. A subclass of that might then provide access to the Struts specific resources, like the MessageResources, ActionMappings, ActionForwards, and ActionForms. That should be about it really. MessageResouces - provides localised messages and labels. ActionForward - provides a logical name for an URI, so it is not embedded in the page. ActionForms - a JavaBean buffer for HTML controls, with a hook for automatic validation. ActionMappings - a configuration object for a server-side Action. Most often the target for a HTML form. These are the framework specific objects, but developers are always tossing in their own JavaBeans, and Vectors, and what-have-you, into the servlet request or sessions contexts, in the same way the VelocityContext is used (I imagine). So, the other first step, along with Donnie's bean, I think, is to chain the request, session, and application contexts to a VelocityContext, behind a facade. Konstantin Priblouda wrote: Hm. If I recall, I did get it to work. The point is not to reinvent the wheel here, but integrate. It's been a while since I did this, but if I recall, it's bean:message because its using a regular bean that does the actual message stuff. Hmm, I looked inside on sunday, and found that message getting stuff actually lives inside RequestUtils and isinfested with PageContext stuff ( mostly for generating stupid jsp exceptions in case property no existed while it would be enough to display property key instead ) Struts is VERY jsp-centric... regards, = Konstantin Priblouda ( ko5tik )Freelance Software developer http://www.pribluda.de play java games - http://www.yook.de render charts online - http://www.pribluda.de/povray/ __ Do You Yahoo!? Buy the perfect holiday gifts at Yahoo! Shopping. http://shopping.yahoo.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- Ted Husted, Husted dot Com, Fairport NY USA. -- Custom Software ~ Technical Services. -- Tel +1 716 737-3463 -- http://www.husted.com/struts/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Struts + Velocity
Geir - Just wondering if you have done anything else on that side project? I didn't see a whole lot of feedback on the list regarding your original post. Did you get interested parties replying to you directly? I'm sad to say it...but it looks like the other members of my team are leaning towards Struts for an out of the box controller framework... and are also leaning to using the JSP and custom tags Struts provides. Aside from loading up your sample app on our test server and having a bit of a look around, I haven't had time to do much else. Cheers, Timothy