7 Replies Latest reply on Mar 31, 2008 5:39 PM by Marcell

    Convertors validators

    kaboel kramer Newbie

      convertor -validator get at  parameters



      in xhtml i specify  the  parameters


      but  I can not get  at  thise  parameters  from the code



      is  there any way to find  out parameter  contents??

        • 1. Re: Convertors validators
          Olivier Thierry Apprentice

          If I remember well, I had to add @BypassInterceptors annotation to my converter / validator Seam component class to make it work. Hope it will help.

          • 2. Re: Convertors validators
            kaboel kramer Newbie

            I's  not  an annotation problem
            The context   of a Convertor  is  the tag (outputText)


            I would  like to read the  XML attributes  of


            f:convertorxxx  

            • 3. Re: Convertors validators
              Pete Muir Master

              You're going to need to explain yourself a lot more clearly than this to get help.

              • 4. Re: Convertors validators
                Marcell Newbie

                There are 2 ways:



                1. JSF way: every property with f:converter will be bind to a bean pproperty in your validator class (remember that it is a string no EL). You need to implement StateHolder to save this properties with the validator. Look here the DateTimeConverter of JSF.




                1. My way :-): add a <f:attribute name="yourPropertyName" value="#{} or anything" /> and at the validator use component.getAttributes().get("yourPropertyName") to retreive the String. This way you don't need to implement StateHolder as the property will be properly saved with the component.



                Summaryzing the uses:



                1. JSF



                <c:inputText ...>
                   <f:converter someProperty="foo" converterId="seamname" />
                 </c:inputText>
                
                @Name("seamname")
                @BypassInterceptors
                @Converter
                public class YourClass implements Converter, StateHolder {
                  private String someProperty;
                  public String getSomeProperty() {
                    return someProperty;
                  }
                  public void setSomeProperty(String value) {
                    someProperty = value;
                  }
                  ... // ValueHolder and Converter methods
                }




                1. My way



                <c:inputText ...>
                   <f:converter converterId="seamname" />
                   <f:attribute name="someProperty" value="someValue" />
                 </c:inputText>
                
                @Name("seamname")
                @BypassInterceptors
                @Converter
                public class YourClass implements Converter {
                  private String getSomeProperty(UIComponent component) {
                    Object o = component.getAttributes().get("someProperty");
                    return o != null ? o.toString() : null; // or "".
                  }
                  // Converter methods that retrieve the property value with the method above
                }



                Hope that helps.

                • 5. Re: Convertors validators
                  kaboel kramer Newbie

                  I'm going to try  that immediatly
                  in any case  already a big  thanks.
                  I'll get back to you

                  • 6. Re: Convertors validators
                    kaboel kramer Newbie

                    The  myway
                    works  like a dream,   thanks a lot


                    I still heve  problems  with  the JSF way
                    in the sense  that  some EL expressions  do not get
                    translted (State Holder seams  to play special tricks)


                    I did  not  Use  as  Seam Vonvertor



                    @Name(seamname)
                    @BypassInterceptors
                    @Converter



                    since  I've  doubths on  where  to place  the module
                       (seam injection   and  seam propertie)
                    I classify  in the facelets (web-Inf) area



                    But  all that  I can live  with.



                    A thousand thanks.


                    • 7. Re: Convertors validators
                      Marcell Newbie

                      I couldn't understand your last concerns this time.
                      Try again :D