0

I'm developing a web application with Struts2 and Twitter Bootstrap.

I've created a simple registration form that uses HTML tags and bootstrap attributes, while the form of Struts uses Struts tags.

Is there a way to integrate them? Below are the two code snippets:

Using HTML and Twitter Bootstrap:

 <div class="row">
    <div class="col-md-6">
          <form class="form-horizontal" action="" method="POST">
          <fieldset>
            <div class="control-group">
              <label class="control-label" for="username">Username</label>
              <div class="controls">
                <input type="text" id="username" name="username" placeholder="" class="form-control input-lg">
                <p class="help-block">Username may contain any letters or numbers, no spaces</p>
              </div>
            </div>

            <div class="control-group">
              <label class="control-label" for="password">Password</label>
              <div class="controls">
                <input type="password" id="password" name="password" placeholder="" class="form-control input-lg">
                <p class="help-block">Password must be at least 6 characters</p>
              </div>
            </div>

            <div class="control-group">
              <label class="control-label" for="password_confirm">Password (Conferma)</label>
              <div class="controls">
                <input type="password" id="password_confirm" name="password_confirm" placeholder="" class="form-control input-lg">
                <p class="help-block">Confirm password</p>
              </div>
            </div>

           <div class="control-group">
              <label class="control-label" for="email">E-mail</label>
              <div class="controls">
                <input type="email" id="email" name="email" placeholder="" class="form-control input-lg">
                <p class="help-block">Insert your email</p>
              </div>
            </div>

            <div class="control-group">
              <!-- Button -->
              <div class="controls">
                <button class="btn btn-success">Confirm</button>
              </div>
            </div>
          </fieldset>
        </form>

    </div> 
  </div>

Form in Struts:

<s:actionerror/>

<s:form action="Registrazione" method="POST" id="formRegistrazione">
    <p align="center">Inserisci i tuoi dati per registrarti al sistema: </p>
    <s:textfield name="user.username" label="Username" />
    <s:password name="user.password" label="Password" />
    <s:password name="user.confermaPassword" label="Confirm Password" />
    <s:textfield name="user.email" label="Email"/>
    <s:submit value="Registrazione" align="center" />
</s:form>
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
Matteo
  • 35
  • 8
  • 1
    Sure there is, it is called Struts2-bootstrap-plugin. Read more on [this answer](http://stackoverflow.com/a/28558436/1654265) – Andrea Ligios May 29 '15 at 10:21
  • @AndreaLigios grazie per la risposta, comunque ho un problema. Nel progetto attuale si usa Struts2-core 2.0.11. Ho provato ad importare tramite Maven Struts2 Bootstrap Plugin a varie versioni ma in ogni caso genera errore (Unable to load bean: type:org.apache.struts2.views.TagLibraryDirectiveProvider class:com.jgeppert.struts2.bootstrap.views.BootstrapTagLibrary). – Matteo May 29 '15 at 12:08
  • You're welcome Matteo, please remember to always speak English on SO so that the discussions can help future users; Struts 2.0.11 is SEVEN years old, VERY buggy and it lacks of seven years of innovation, security fixes, and last but not least, you can't use almost any recent plugin with it, like the bootstrap or jquery ones. Take a tour of the [Security Bulletin](http://struts.apache.org/docs/security-bulletins.html) and feel free to be scared. Consider upgrading to 2.3.24, no matter what the standards are or the boss says, he's wrong... fight for it, there is no reason to stay on 2.0.11. – Andrea Ligios May 29 '15 at 12:26
  • @AndreaLigios I apologize're right answer in English. However the problem is not to update the dependency of Struts2 (I fully agree with you), the problem is that if I upgrade the dependency to a more recent project does not compile because there are big differences, and so you have to go analyze them where They are errors, and fix them. Unfortunately, time is running out and therefore I do not think it will be easy to match things. Thanks anyway for your precious help! – Matteo May 29 '15 at 12:32
  • Then I guess you will need to use plain HTML tags for Bootstrap. Remember to upgrade for your next project... however if you are not using DMI, things could be adapted faster than it seems. I migrated two of my projects from 2.0.14 to 2.3.x two years ago in a couple of hours. – Andrea Ligios May 29 '15 at 12:35
  • @AndreaLigios Can you explain me how is DMI? However, the error is: GRAVE: Exception starting filter struts2 Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean ... – Matteo May 29 '15 at 12:38
  • Leave the error alone, you won't be able to make it work with such an old version, so forget it. DMI is Dynamic Method Invocation. [Read more here](http://stackoverflow.com/a/13336391/1654265) and [the alternatives here](http://stackoverflow.com/a/20746720/1654265) – Andrea Ligios May 29 '15 at 12:40
  • @AndreaLigios sorry but I find hard to follow you. What are you going to leave the error? That can't be resolved because the version of Struts is too obsolete? There is a procedure to update the version of Struts in a "safe mode"? – Matteo May 29 '15 at 12:47
  • Let me be crystal clear: (1) no upgrade, no plugin (2) there is not a *safe procedure* to upgrade from 2.0 to 2.3, but if you are not currently using DMI, it might be easier than you think (hours); there are 5-6 different things to change, after you know them, it is just a matter of repeating the operation on your files. If you are using DMI, instead, it might be quite longer (days). – Andrea Ligios May 29 '15 at 12:50

0 Answers0