11 Replies Latest reply on Oct 10, 2007 3:00 PM by holgerprause

    h:message for / s:decorate question

    holgerprause Newbie

      Hello,

      first of all ill explain what i want to do and then let me ask if its possible with seam

      look at the following code, it displays an error message for an input field

      <h:inputText id="myInput" required="true" value="#{TestBean.value}" errorStyle="color:red" />
      <h:message for="myInput" />
      


      This will produce the following output:
      "myInput":Value required

      The thing is that if you use the "for" attribute of a <h:message> tag
      It will display the id of the inputText in the resulting error message "myInput":Value required

      Thats a very very ugly behaviour becourse:
      1) if you want to support internationalization you have to localize the ids!(id should be unique and identify sth, and an id is not a label! - very very bad idea) or you have to use <h:messages> to display all messages-
      2) i use the ids for updating issues, i cant localized them and ids cant contain spaces, as i already said in point 1 its very stupid design(in my opinion)

      I whish it could be like this
      <h:inputText id="myInput" required="true" value="#{TestBean.value}" errorStyle="color:red" label="#{messages['myInput']}" />
      <h:message for="myInput" />
      


      So what to do now?
      My question is: Is this possible to either get rid of the id string in the error message(and still use the for attribute) or to localize the id part of the error message(without actually changing the value of the id attribute) without programming anything ?
      (Just with the seam s:message or h:message tags)

      OR

      Do i have to programm my own inputText and message implementation?
      (And how to start with that).Will s:decorate still work with my own implementation(i doubt it) ?

      Hmm just some words on JSF:
      I am using jsf for a while now and i am wondering if any of the designers actually use their own framework, such simple things(and many many more) are not possible, very inflexible and far away from daily work, seriously....
      JSF sucks but whats worse, JSF is best Java Web Framework currrently.

      Anyway thx for your help, and it could all be worse ^^

        • 2. Re: h:message for / s:decorate question
          holgerprause Newbie

          I am using the js implementation coming with jboss-4.0.5.GA ()

          i specified the label attribute on the inputText, still same behaviour.
          Well guess ill try to update the jsf implementation libs on my jboss server

          I realized that the newest myfaces implemenations are horrible slow so i tried to avoid an update.

          Sigh ok ill post here when i am done with it , thx for your quick help pete.

          • 3. Re: h:message for / s:decorate question
            Pete Muir Master

            You should use the JSF RI (1.2) - instructions in the ref manual for 1.2.1 on how to upgrade iirc.

            • 4. Re: h:message for / s:decorate question
              holgerprause Newbie

              Hello i update to the newest myfaces jar , same behaviour, i am currently
              trying to upgrade to jsf-1.2_04-b07

              but i get the error message

              java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory

              I guess i have to update the jboss server too.
              I just want to upgrade the jars , damn its all so complicated oo.

              Il post here if i get it to work

              • 5. Re: h:message for / s:decorate question
                holgerprause Newbie

                If u want to upgrade to jsf 1.2 too, take a look here:

                http://www.jboss.com/index.html?module=bb&op=viewtopic&t=94738

                I am switiching to last jboss server, i let u know if i get it (finally) to work.

                • 6. Re: h:message for / s:decorate question
                  holgerprause Newbie

                  well i try also to get tomahawk working together with jsf ri.

                  wish me luck - good night

                  • 7. Re: h:message for / s:decorate question
                    holgerprause Newbie

                    Now i finally upgraded everything the behaviour is slightly better, but still not like expected:

                    I am using latest jsf ri implementation and jboss-4.2.1.GA

                    in my messages.properties

                    myInput=Label for my Inputfield
                    


                    in my facelets page
                    <h:inputText id="myInput" required="true" value="#{TestBean.value}" errorStyle="color:red" label="#{messages['myInput']}" />
                    <h:message for="myInput" />
                    


                    The output should be:
                    "Label for my Inputfield": Value required
                    


                    but in fact it is:
                    Value required
                    



                    He seems to ignore the label attribute, and i am getting insane on this :-/
                    Pls help, well at least this behaviour is slightly better than before.

                    Do i really have to rewrite message tag to get this to work?

                    Thx very much ,

                    Holger





                    • 8. Re: h:message for / s:decorate question
                      Christian Bauer Master

                      Man, just configure your messages.properties file - there are many examples and documentation - and override the message. Done.

                      • 9. Re: h:message for / s:decorate question
                        holgerprause Newbie

                        I dont think u got it right, my message properties file is just as it should, the
                        entry that should be used as label is there and configured.

                        Its just the h:message tag in combination with the h:inputText tag that just dont work together.

                        The code i posted (the 2 lines) are so simple, well what can i do/is wrong, its just like in the documentation, i spent a whole day on this.

                        • 10. Re: h:message for / s:decorate question
                          holgerprause Newbie

                          Well finally i found out how to(semi dirty workaround in my opinion)

                          Dont override the required message in your messages.properties
                          It will take effect for all your input fields where required is specified

                          When u got an internet application with just 1 form field thats maybe an solution

                          Instead specify the requiredMessage attribute on inputText tag

                          <h:inputText id="myInput"
                           requiredMessage="#{messages['inputLabel']}: #{messages['javax.faces.component.UIInput.REQUIRED']}"
                           value="#{TestBean.value}"
                           required="true" />
                          <h:message for="myInput" />
                          


                          Do the same for validation and converter messages, if your validator or converter outputs different message u got a problem becourse the decision what error message to output have to be made in the facelet via the
                          validatorMessage attribute.

                          From jsf 1.2 api

                          ...will be used as the text of the validator message, replacing any message that comes from the validator.


                          The problem on this approach is the you override the default messages coming from the pre defined validators.

                          Maybe its all working in your enviroment better.

                          Well anyway i like seam but i dont like jsf
                          Bye and thx,

                          Holger



                          • 11. Re: h:message for / s:decorate question (cause of the proble
                            holgerprause Newbie

                            Well first of all sorry to all for the confusion.

                            First of all 1 thing:

                            1) its working like expected (upgrade to jsf 1.2 and use label attribute )

                            I was so sure that my message template(generated from redhat developer studio) was the same like in the jsf implementation and that i am doing everything right, but that was wrong.

                            //from generated messages_en.properties
                            javax.faces.component.UIInput.REQUIRED=value is required

                            //from jsf impl.jar
                            javax.faces.component.UIInput.REQUIRED={0}: Validation Error: Value is required.

                            so why i thought that label attribute is ignored was that missing
                            {0}: in my properties file

                            christian.bauer@jboss.com wrote:


                            Man, just configure your messages.properties file - there are many examples and documentation - and override the message. Done.


                            When i read this i was so angry course i was so absolutly sure that it has nothing to with the properties file and that i was treated like a noob.

                            Well what to say, chrisitan was absolutly right :-)

                            I am such a damn noob(i admit it).To my excuse - that was a simple but mean little problem.
                            Sorry again for spamming forum.

                            But let me say this at least : i still dont like jsf. XD

                            Thx very much its finally working all and me very happy now.
                            With best regards / whishes (Dont give up - its mostly worth it)

                            Holger