3

In my Struts 2 application I am trying to add CSS style, but it is not displaying on the page. When I click on the submit button two times and after showing validation error only then CSS is displaying. Please tell me what is the resume of this kind of problem my form is here

<%@ page language ="java" contentType ="text/html; charset=ISO-8859-1" pageEncoding ="ISO-8859-1"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="/struts-dojo-tags" prefix="sx" %> 
 <html>
    <head>
       <sx:head/>
    <script type="text/javascript"  src ="script.js"></script>
   <link rel="stylesheet" type="text/css" href="css/emp.css">
        
    </head>  
    
<body>
          
        <div id ="did" align="center"> <h1 style="color: red">  ENPLOYEE REGISTRATION FORM</h1>
       
   <s:form  action="emplogin"  method="post" >
      
      <s:textfield name="firstname" label="Employee Firstname"/>
      <s:textfield name ="lastname" label ="Last name"/>  
      <s:textfield name ="id"  label="Id"/>
      <s:radio name ="gender"   list="{'male', 'female'}" label = "Gender"/>
    <sx:datetimepicker name="dob" displayFormat="dd-MMM-yyyy"  label="DOB"></sx:datetimepicker> 
      <s:radio  name ="maritalstatus" list="{'singale','married'}" label="Marital Status" />
       
      <s:textfield name ="email" label ="Email" />
 <sx:datetimepicker name ="joiningdate" displayFormat="dd-MMM-yyyy" label="Joining Date" ></sx:datetimepicker>
      
      <s:textfield name= "designation" label = "Designation"/>
      <s:textarea name ="address" label ="Address" />
      <s:textfield name = "country" label ="Country" />     
      <s:textfield name  ="state" label = "State" />
      <s:textfield name  ="city" label ="City"/> 
      <s:textfield name ="pincode" label ="Pincode"/>
      <s:textfield name ="mobileno" label="Mobile No"/>
      <s:select   name ="groups" list="{'group 1', 'group 2', 'group 3'}"  label ="Group"  />
     <tr><td>&nbsp;</td></tr>
        <tr>
    <td>&nbsp;</td>
      <s:submit align="center"></s:submit>
      </s:form>
       </div>
    </body>
 </html>

CSS file is:

#did
{background-color:#6495ed;}

#trasition
{
transition: width 2s;
-webkit-transition: width 2s; 
} 
Roman C
  • 49,761
  • 33
  • 66
  • 176

1 Answers1

1

You have mistake with the syntax of the style attribute

you should replace this

cssStyle="{width:184px"

to

cssStyle="width:184px;"

also dojo tag library is deprecated in struts2 since version 2.1. Use struts2-jquery instead.

Roman C
  • 49,761
  • 33
  • 66
  • 176
  • I am not asking about that my problem is when i am using css from an external file which i described in section it is only working when i am clicking submit button e times not directly. I am just trying to change color of baground. –  Apr 10 '13 at 11:13
  • @tom struts2 applying theme on the elements. use the theme you want for the custom formatting or simple theme to define a custom theme for your barebone html elements. – Roman C Apr 10 '13 at 11:20
  • can you just tell me why normal way css is not working in my page and when clicking on submit button 2 times(after validation message)it only working –  Apr 10 '13 at 12:42
  • @tom the document has errors and not point to the browser what it is and how it could be render html, version etc. If youare using `devMode` better to turn it off to produce seamless result to the viewer. – Roman C Apr 11 '13 at 10:55
  • Even after turning of devmode it is not working .Is there any connection b/w css and struts2 validation? –  Apr 11 '13 at 11:41
  • Has nothing rather than using theme to render validation errors. – Roman C Apr 11 '13 at 11:45