RE: [Q] Is Struts use of BeanUtils and PropertyUtils inconsistent?
Hi Craig- thanks for the reply. You mention that: The conversions on form submit are required because HTTP request parameters are all strings. which I understood perfectly well. I also understand that, in order for that conversion to work for things like date, a common format must used inbound and outbound. Struts does not have any innate knowledge of your model tier's requirements, and in particular does not know what the caller of RequestUtils.lookup() is going to do with the data that is returned. Doing that by itself would break a huge number of apps that depend on RequestUtils.lookup() working the way it does. I agree here too. Struts shouldn't know, and it never will. When a date is inbound, Struts knows just enough to invoke the converter associated with the Class/Type and that's it. And that's how it should be. But, I'd argue that since the caller of RequestUtils.lookup in this case is a view component (a tag), it should be smart enough to know about the formats I want applied to the information it is rendering. I think you're right that we shouldn't tamper with RequestUtils. It sounds like you'd be better off creating a customized version of the bean:write tag that does the conversion for you. That wouldn't be particularly difficult to implement. However, do you think it's worth considering modifying the bean *and* html tags to recognize edit masks/display formats? Most of the Struts work I'm doing now involves re-creating old Oracle Forms applications as JSP/EJB kinds of applications. Edit masks have been a pretty standard view side concept for decades now. Adding masks as attributes of the tags might be a simple way to implement this feature. Also, I realize there are a bunch of other hacks I could employ like breaking dates into three separate input boxes, but I'd rather hack as a last resort. And beyond dates, I can think of many other applications of formats to simplify rendering of data in the JSP. thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [Q] Is Struts use of BeanUtils and PropertyUtils inconsistent?
See below. On Mon, 17 Feb 2003, Jim Krygowski wrote: Date: Mon, 17 Feb 2003 07:20:27 -0500 From: Jim Krygowski [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: RE: [Q] Is Struts use of BeanUtils and PropertyUtils inconsistent? Hi Craig- thanks for the reply. You mention that: The conversions on form submit are required because HTTP request parameters are all strings. which I understood perfectly well. I also understand that, in order for that conversion to work for things like date, a common format must used inbound and outbound. Struts does not have any innate knowledge of your model tier's requirements, and in particular does not know what the caller of RequestUtils.lookup() is going to do with the data that is returned. Doing that by itself would break a huge number of apps that depend on RequestUtils.lookup() working the way it does. I agree here too. Struts shouldn't know, and it never will. When a date is inbound, Struts knows just enough to invoke the converter associated with the Class/Type and that's it. And that's how it should be. But, I'd argue that since the caller of RequestUtils.lookup in this case is a view component (a tag), it should be smart enough to know about the formats I want applied to the information it is rendering. I think you're right that we shouldn't tamper with RequestUtils. It sounds like you'd be better off creating a customized version of the bean:write tag that does the conversion for you. That wouldn't be particularly difficult to implement. However, do you think it's worth considering modifying the bean *and* html tags to recognize edit masks/display formats? The bean:write tag already has a format attribute that works like this. I'm not personally interested in adding this kind of thing to the other tags (my long term plan is to use JavaServer Faces components instead), but it's possible that other Struts committers will be interested in this. Most of the Struts work I'm doing now involves re-creating old Oracle Forms applications as JSP/EJB kinds of applications. Edit masks have been a pretty standard view side concept for decades now. Adding masks as attributes of the tags might be a simple way to implement this feature. Also, I realize there are a bunch of other hacks I could employ like breaking dates into three separate input boxes, but I'd rather hack as a last resort. And beyond dates, I can think of many other applications of formats to simplify rendering of data in the JSP. The best way to get something like this included in Struts would be to post enhancement requests to the bug tracking system: http://nagoya.apache.org/bugzilla/ and then attach patches to implement the proposed changes, as outlined starting at: http://jakarta.apache.org/site/getinvolved.html Then, it's just a matter of talking with the developers about incorporating the changes in some appropriate version of Struts (we're trying to lock down 1.1 at the moment, so it won't go there no matter what). Worst case, at least you'll have the tags implemented the way you like so that *you* can use them. Best case, you'll get an @author tag on a bunch of Struts classes :-). thanks. Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Q] Is Struts use of BeanUtils and PropertyUtils inconsistent?
On Fri, 14 Feb 2003, Jim Krygowski wrote: Date: Fri, 14 Feb 2003 13:50:33 -0500 From: Jim Krygowski [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: [Q] Is Struts use of BeanUtils and PropertyUtils inconsistent? Hi- I noticed that when a request is processed by RequestUtils and its values are copied into an ActionForm, Struts uses the BeanUtils class. Deep inside BeanUtils, the method for copying (getSimpleProperty) uses ConvertUtils's convert() method before returning the requested value. However, all the tags in Struts use RequestUtils.lookup, which in turn uses PropertyUtils and the getSimpleProperty method on PropertyUtils doesn't use the converter utilities. This seems somewhat inconsistent. I know Craig and a few others on the list advocate creating parallel String-only value objects and then manually converting (using BeanUtils) in the action. Their reasons are valid, but add a lot of extra work especially if you're rendering non-trivial object graphs, (n deep X n wide). My app has about 70 value objects right now and I'd hate to create and maintain 70 parallel string-only value objects. Beyond even that issue, what's the point of doing a conversion inbound if you're only ever going to deal with Strings? The conversions on form submit are required because HTTP request parameters are all strings. Struts does not have any innate knowledge of your model tier's requirements, and in particular does not know what the caller of RequestUtils.lookup() is going to do with the data that is returned. My ideal would be to allow for conversion outbound. This would require switching from PropertyUtils to BeanUtils in the RequestUtil.lookup. Maybe this is a good feature for Struts 1.1b4? What do you think? Doing that by itself would break a huge number of apps that depend on RequestUtils.lookup() working the way it does. It sounds like you'd be better off creating a customized version of the bean:write tag that does the conversion for you. That wouldn't be particularly difficult to implement. Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]