4 Replies Latest reply on May 20, 2014 6:17 AM by matic.petek

    Errai UI : conditions in HTML

    matic.petek

      Hi,

      Is is possible to set conditions in HTML template? So you can use some block of HTML code base on state of Java variable. Or should I use DOM manipulation (like example 10.6.1.1. Composite component class).

      Thank you

      Regards,

        Matic

        • 1. Re: Errai UI : conditions in HTML
          magick93

          Sounds like you want to use a producer - Producers - Errai - Project Documentation Editor

          • 2. Re: Errai UI : conditions in HTML
            matic.petek

            Hi,

            Thank you Anton. But I don't really think this is solution for my problem. I would like to have the some Java class for HTML template, but conditions inside HTML templates. For example :

             

            +++++ MyTemplate.html

            <form>

              <legend>Log in to your account</legend>

              <label for="username">Username</label>

              <input id="username" type="text" placeholder="Username"> 

              <#if show_input_password??>

               <label for="password">Password</label>

               <input id="password" type="password" placeholder="Password">

              </#if>

              <button>Log in</button>

              <button>Cancel</button>

            </form>

             

            +++++ MyTemplate.java

            @Templated

            public class MyTemplate extends Composite {

              Boolean show_input_password;

            }

             

            Regards,

              Matic

            • 3. Re: Errai UI : conditions in HTML
              csa

              Hi Matic,

               

              This isn't possible inside the template as we want our templates to be plain/standard conform HTML5 so they can be rendered in the browser directly (without having to pass them through a template engine when designing the UI).

               

              So, you will need to do this in Java code, either by injecting a different composite (that is based on a different template) i.e. using a producer as Anton suggested or doing it programmatically.

               

              Cheers,

              Christian

              • 4. Re: Errai UI : conditions in HTML
                matic.petek

                Hi Christian,

                  Thank you for reply. I have discussion about this with my coworker and find out the some thing - we will use different composite.

                Regards,

                  Matic