2

I have this form.

<s:form action="register">

      <s:textfield class = "formfield" name="userBean.username" label="User Name" />
      <s:textfield class = "formfield"  name="userBean.password" label="Password" />
      <s:textfield class = "formfield"  name="profileBean.firstName"  label ="First Name"/>  
      <s:textfield class = "formfield"  name="profileBean.lastName"  label="Last Name"  />
      <s:textfield class = "formfield"  name="profileBean.Age"  label="Age"  />

      <s:submit/>
</s:form>   

What I wanted to do is provide it custom styling through css, but the problem is it is not being applied, what is the solution for this? our designers will style our form using css but however, there styling could not be applied if we convereted their form in struts tags

What we are aiming to do is to style it similar to how you style input tags

4

2 に答える 2

3

I think you are suppose to use the attribute cssClass

e.g. <s:textfield cssClass = "formfield" name="userBean.username" label="User Name" />

于 2012-12-17T13:27:08.427 に答える
2

As said in the other answer, you must use cssClass instad of class, and cssStyle instead of style.

If you note that the behaviour of Struts2 components is different from standard HTML components, it is due to Struts2 Themes and Templates.

The default theme is XHTML;

For example,

when you set label attribute on your <s:textfield/> tag, it will create the html <label/> element before the <input="text"/> tag. If you don't want that, you can specify theme="simple" in your <s:textfield/>, or in your <s:form/> to apply the setting to all the contained elements.

于 2012-12-17T14:03:57.353 に答える