1 2 Previous Next 15 Replies Latest reply on Feb 5, 2007 4:06 AM by sbublava

    An easy DatePicker component with Seam?

    smokingapipe

      What's the easiest way to make a date picker component in Seam? I'm using Seam with Facelets and I couldn't find anything about one being built in. This is Seam 1.1.0, although I will soon be upgrading to 1.1.5. I have not installed Icefaces or anything like that and I would like to avoid the complexity of figuring that all out at this point.

      Thanks

        • 1. Re: An easy DatePicker component with Seam?
          djeverson

           

          <h:inputText id="checkinDate" value="" required="true">
           <s:convertDateTime pattern="MM/dd/yyyy"/>
          </h:inputText>
          <s:selectDate for="checkinDate">
           <h:graphicImage url="img/dtpick.gif" style="margin-left:5px"/>
          </s:selectDate>
          


          • 2. Re: An easy DatePicker component with Seam?
            smokingapipe

            Are you serious? That's it? I'll give it a try.

            • 3. Re: An easy DatePicker component with Seam?
              gavin.king

              You are also going to need to copy/paste the css from the booking demo.

              • 4. Re: An easy DatePicker component with Seam?

                Should we add the option to generate the default inline CSS from the date picker?

                • 5. Re: An easy DatePicker component with Seam?
                  gavin.king

                  Can you specify css inline? I thought it has to go in the header section...

                  • 6. Re: An easy DatePicker component with Seam?
                    smokingapipe

                    I got it working. It's cool! I didn't even know it was there.

                    Comments: The datepicker image file (dtpick.gif) needs to be in the application or the icon won't show up and you'll be wondering, where did the date picker go.

                    Second, yes, there does need to be some CSS somewhere because the background it transparent so the calendar display paints over the rest of the page and is hard to read.

                    I'm looking at the booking example CSS right now to see if there's a line I can put in my CSS file that will fix that.

                    • 7. Re: An easy DatePicker component with Seam?
                      smokingapipe

                      Ah there is a handy file right there in booking called date.css. I'm going to install that in my app, and presumably it will start working.

                      • 8. Re: An easy DatePicker component with Seam?
                        smokingapipe

                        I put date.css i there and it worked nicely. And due to the coolness of Faclets I just modify one template file and date.css is available on every page. One thing that went away when I installed date.css is it no longer shows the "today" button. I'll have to look in the css to change that.

                        So, the comments are, a) make sure the date picker icon is present in your application and b) make sure date.css is linked in, or it won't look good.

                        With those two in place it's very cool and I like how it works with a regular text field, so someone can also type a date and not mouse arround if not desired.

                        • 9. Re: An easy DatePicker component with Seam?
                          smokingapipe

                          By the way, this datepicker thing brings up the whole issue of external resources. I just looked at my page's sourcecode and noticed that there is (not surpingly) JavaScript all over the place. My understanding is that script elements only properly belong in the head element of HTML, and ideally they should actually be external to the page itself, in a separate URL. Same with CSS elements, handy icons, etc. I assume the answer on this is "yes", but the question is, is Seam or JSF going to have a mechanism for components to specify external dependencies, and then have all those external resources be truly external to the generated page? Or is this actually not a good idea for some reason? I'm just thinking that for things like the date picker, the JS for that will never change, so why send it as part of every page? In the case of a small piece of JS like the date picker this doesn't matter, but no doubt we will be seeing bigger components, like GUI type editors, etc, which you can't practically send with every page.

                          • 10. Re: An easy DatePicker component with Seam?
                            cavani

                            I want to suggest two improvements: dropdown for year selection and same for month.

                            http://jira.jboss.org/jira/browse/JBSEAM-763

                            could be?

                            • 11. Re: An easy DatePicker component with Seam?

                              The javascript is actually dynamically generated with data for the the locale. We'd have to do some refactoring to make it work, but it is quite doable. Unfortunately, we run into the same problem we have for CSS. We don't have a mechanism to generically serve content off of the classpath.

                              I suggested some time ago integrating something like Weblets (https://weblets.dev.java.net/) into Seam because I think this will be a common need for projects. Anyone out there have experience with it?

                              • 12. Re: An easy DatePicker component with Seam?
                                smokingapipe

                                It seems to me there will be more and more need to serve content out of the classpath for Seam. What about when it needs to start serving SVG files, Flash files, or other media content? All these things are going to come up more, not less, and having them integrated into Seam and ready to go would make them much more component-like.

                                • 13. Re: An easy DatePicker component with Seam?

                                  Did you take a look at weblets? What do you think of something like that in the context of Seam?

                                  • 14. Re: An easy DatePicker component with Seam?
                                    smokingapipe

                                    I looked at that. I haven't tried it but it sounds exactly like what is needed: a way to let JSF components have dependencies that are external to the page (html) being rendered. This is going to be more and more of a need as time goes on, because, as I said, I'm sure we're going to start wanting Flash files and tons of other stuff. Like I might have a component that's s:playMusic, that would render as a Flash player for a music track. That will need the flash file, and then it will need to be able to serve the music data. Ideally, the "Seam way" would be to have the component just work without me needing to do anything else.

                                    1 2 Previous Next