Sure, I understand completely now. You aren't doing anything unusual at all :)
I think because you came from an ASP.Net background, you have some expectations that don't apply with Struts (I too came from an MS background, although before .Net appeared, so I've fought the "why doesn't it work THIS way?!?" syndrome too). With Struts, there is no separation of page prep and control events. In other words, if you want to submit to the server to update your calendar, you will be responsible for rendering the rest of the page, including any input the user might have made since the last trip to the server. Struts can't do this for you, as ASP.Net can. So, in your case, you really have two options... (1) Do the calendar work client-side. I do this with my calendar controls, which look, feel and work very much like the celendar widget you get in Windows. However, when you change the month or year, there is no trip to the server... The calendar is regenerated on the client-side. This is of course Javascript/dHTML-based work. (2) If you really do want to post back to the server to do this, you'll need to deal with the rest of the page as well. I don't know what else is on it in your case, but for instance if there's five other text fields, you'll have to grab them from request and populate an ActionForm that you'll use in your JSP to rebuild it. As for specifically submitting the calendar values, what you said in the first place is the right answer... Your <calendar> tag should render some hidden form fields, then you'll have to still do some scripting to populate them when the calendar is clicked, then call submit() on the form, then like I said rebuild the entire page and render it to the client. It's actually pretty straight-forward, but you get into the question of whether it's better done on the client or not. FYI, from the little bit I know of it, JSF deals with the problem much like ASP.Net does, but separating out page prep and event handling. It is my understanding that much of the "extra" work you'll have to do here in re-rendering the page is handled by JSF for you. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com On Tue, January 18, 2005 11:43 am, Peter Wu said: > Frank W. Zammetti <fzlists <at> omnytex.com> writes: > >> I need to understand a little bit more what you have now... When you >> have your <calendar> tag in the JSP, it of course renders HTML on the >> browser (or are you rendering a link to an ActiveX control or >> something?). > > It is not an ActiveX control. If it were an ActiveX control, then it would > be > easier to deal with but harder to port to different environment. ActiveX > can > only work on Microsoft Windows family. > > Let me give you an example of what I'm going to do. > > If you do online banking, you can set up bill payments on specific dates. > Usually, the online banking web interface provides a calendar for your > select > the date on which the payment will occur. > > Typically, the default date is today and, if you change the month or the > year, > the calendar itself refreshes itself by displaying the days in the month > of > the year you have selected. > > Obviously, when you select a new month or a new year, the html page that > accomodates the calendar control should post back to the server and render > the > page again with the correct days displayed. > >> Where you say: >> >> > Those pure HTML controls work very well with this approach. But how >> can my custom control work like this? >> >> That makes it sound like to me that you actually are dealing with an >> ActiveX control. Could you clarify that for me before I try and help >> any further? I have an answer either way, just want to make sure I'm >> giving the appropriate one :) > > Sorry for the confusion. > > By "pure HTML controls", I meant those <html:form>, <html:text> tags > introduced in Struts after you declare them in the web.xml. > > <taglib> > <taglib-uri>/tags/struts-html.tld</taglib-uri> > <taglib-location>/WEB-INF/struts-html.tld</taglib-location> > </taglib> > > >> Also, in anticipation of your answer... when the user clicks a date, is >> your thinking that the page they see should change, i.e., they should >> move on to another screen, or are you thinking you just want an error >> message (or no error message if it's a valid date) on the SAME screen? > > Yes, the page should change by posting back to itself and display > respective > days of the month you've selected. > > I want to use this control in future projects. For, this control should > only > be responsible for displaying a calendar. > > So, in the JSP page, I want to simply to a calendar tag like: > > <html> > <body> > <form> > <calendar /> > </form> > </body> > </html> > > If necessary, we can add necessar attributes to the <calendar> tag. Once > the > page is submitted to the server, I can catch the date selected via the > calendar control and do something accordingly. > > Just like a textbox control on an HTML page. You enter some value in the > textbox and submit it to the server for processing. In my case, I'm just > finding out a way to submit the selected date of the calendar to the > server > and have the information processed. > > Hope this makes things clear. :-) > > > Thanks! > Peter > > > > > > --------------------------------------------------------------------- > 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]