Vibhor Bhardwaj
Vibhor Bhardwaj

Reputation: 3101

How to apply struts2 tags on existing jsp file without affecting its css and js

I was given a HTML page I changed it's extension .jsp. I want to make dynamic web application using struts. My Html page code is like this..

<div id="content">
    <div class="subpage-border-top">
        <div class="subpage-border-bottom">
            <div class="subpage-border-mid">

                <div class="loginpage-bottom">
                    <h2>Login</h2>
                    <div class="loginpage-mid">
                        <span>Enter your email address and password to login</span>
                        <ul>
                            <li><label>Email</label>
                                <div class="right_input">
                                    <input type="text" value=""
                                        onblur="if(this.value=='')this.value=this.defaultValue;"
                                        onfocus="if(this.value==this.defaultValue)this.value='';"
                                        class="o-que email-text" />
                                    <!-- <strong> dshmbf,sdmhfdi</strong>-->
                                </div></li>
                            <li><label>Password</label>
                                <div class="right_input">
                                    <input type="password" value=""
                                        onblur="if(this.value=='')this.value=this.defaultValue;"
                                        onfocus="if(this.value==this.defaultValue)this.value='';"
                                        class="o-que email-text" />
                                </div> <a href="#" class="forget-password">(Forget Your
                                    Password)</a></li>
                            <li>
                                <div class="remember">
                                    <input type="checkbox" name="" />Remember Me
                                </div>
                                <div class="login-button">
                                    <div>
                                        <input type="submit" value="Login" />
                                    </div>
                                </div>
                            </li>
                        </ul>



</div>
</div>        
</div>

So it's layout looks like this..

enter image description here

And according to a tutorial I want to use struts tags..

<s:form action="User_login">
        <s:textfield label="User Name" key="userName"/>
        <s:textfield label="Password" key="password"/>
        <s:submit/>
    </s:form>

But what should I replace with these struts tags,so my struts can work and my layout(css,java script) remain intact..Please help.

Upvotes: 1

Views: 991

Answers (1)

Andrea Ligios
Andrea Ligios

Reputation: 50203

Your CSS will break because your HTML will change.

Struts2 uses Themes to generate the HTML for each tag; the default theme is XHTML.

Just use SIMPLE theme, that will generate ONLY the tag without any side data (<label> for example).

It can be applied to a single tag, to a form, or globally at application level.

Then try

<s:form action="User_login" theme="simple">` 

; if you are satisfied with the result, set it globally in struts.xml with

<constant name="struts.ui.theme" value="simple" />

Upvotes: 2

Related Questions