5 Replies Latest reply: May 15, 2012 3:57 AM by gimbal2 RSS

    Strange issue in Pure JSF.

    876147
      I am facing a strange issue in PURE JSF. I am using a datepicker from Jquery. When I use the datepicker on regular Jsf Button it does not disappear after posting and reloading the same page. But when I use the datepicker on image button it disappears after posting and reloading the same page.

      For more detail see the below code snippet
      <script>
           $(function() {
                $( ".datepicker" ).datepicker({
                     showOn: "button",
                     buttonImage: "images/IconCalendar.png",
                     buttonImageOnly: true
                });

           });
      </script>

      =========================
      <h:inputText value="#{distributionJob.oneJobType}" id="oneJobType" size="30" class="datepicker" > </h:inputText>
        • 1. Re: Strange issue in Pure JSF.
          gimbal2
          I wonder how you can call some manual javascript meddling "pure JSF".

          Can you make it work without any JSF involved, but by just doing this in some static html file? I don't see how JSF can be in any way involved in this problem, as you pose it now it is a regular javascript/html one.
          • 2. Re: Strange issue in Pure JSF.
            EJP
            Kinda makes you wonder what would qualify as 'impure' JSF.
            • 3. Re: Strange issue in Pure JSF.
              gimbal2
              EJP wrote:
              Kinda makes you wonder what would qualify as 'impure' JSF.
              Hm good question, that would more make me think that it is wrong to even speak of pure or impure because it is too vague a term. But one can make an attempt if it is kept simple: assuming what is meant is "improper use of JSF", I'd keep it at "any way you can make the server side and the client side state go out of sync", which would not apply to the simple example posed in this thread. Manual javascript meddling is a usual suspect though.

              But the main issue is this likely not being related to JSF at all, be it pure or impure ;)
              • 4. Re: Strange issue in Pure JSF.
                876147
                Sorry about “Pure JSF” thing. I wanted to say that I have used JSF2.1 instead of any richfaces or icefaces API.
                Now back to original question.


                I have a JSF page where I post the data and the page uses JQuery datepicker.
                When I use the commandbutton of JSF It works fine and after posting data and reloading the page datepicker is properly shown.
                Instead of commandbutton if I use Jquery button with image then after posting the data and reloading image the date picker is missing.
                I also believe that it is most likely a javascript issue but can not find the rootcause of it.
                If anybody has encountered similar issue and resolved then it would be nice to get the answer
                • 5. Re: Strange issue in Pure JSF.
                  gimbal2
                  user969615 wrote:
                  Sorry about “Pure JSF” thing. I wanted to say that I have used JSF2.1 instead of any richfaces or icefaces API.
                  Now back to original question.


                  I have a JSF page where I post the data and the page uses JQuery datepicker.
                  When I use the commandbutton of JSF It works fine and after posting data and reloading the page datepicker is properly shown.
                  Instead of commandbutton if I use Jquery button with image then after posting the data and reloading image the date picker is missing.
                  I also believe that it is most likely a javascript issue but can not find the rootcause of it.
                  If anybody has encountered similar issue and resolved then it would be nice to get the answer
                  You've now identified that you're in fact doing manual javascript meddling: if you want to submit forms in which JSF is involved, do so using JSF components which tend to boil down to a commandButton or a commandLink. Check out the HTML source of a JSF generated page, you'll see that there is a good amount of javascript attached to such components which is what JSF uses to keep itself synced. As soon as you interfere with that, bad things happen.