Convert Html fields to Struts2 tags
I am new to struts2... I designed a page in plain html.. now i have use this html page in struts2 project.. how can i convert html field elements to Struts2 ui tags ??? My html page looks like:
<tr>
<td class="style4">**Customer Name***</td>
<td><input type="text" name="Scr_Inq_CName" class="body-fieldsTextFields" id="Scr_Inq_CName_id" tabindex="4" onkeypress="return CommonKeyPressIsAlpha(event);"/></td>
</tr>
I have assigned style(style4) to a label "Customer name" and style(body-fieldsTextFields) to text box and also i have performed validation on this..
When i use Struts-tag
It displays text field with style(body-fieldsTextFields) applied, When i run project... But Customer name label is displayed in separate row <tr><td>Customer name</td></tr>
.
And text field is displayed in below table row <tr>
. i found this kind of disorder using FireBug.
开发者_开发问答how to apply style4 to Customer name label and body-fieldsTextFields style to all textfields and also how can i make both label and text field to be displayed in same row ?????
Thanks..
<tr>
<td class="style4">**Customer Name***</td>
<td><s:textfield cssClass="body-fieldsTextFields" theme="simple" name="Scr_Inq_CName" id="Scr_Inq_CName_id" onkeypress="return CommonKeyPressIsAlpha(event);"/></td>
</tr>
This will give you what you want
theme="simple"
will remove the struts styling. cssClass
attribute is used by struts2 tags to use css classes.
Also take a look at Steven's comment.You need to increase your accept rate.
For the alignment problem I guess you have some errors in your CSS rules for style4, you should check if you have put some display:block or similar rules that would make the next cell go under the first, otherwise the html is correct.
If you prefer creating a real label you could do this (I'm using Struts tags):
<tr>
<td><label for="Scr_Inq_CName_id">**Customer Name**</label></td>
<td><html:text property="Scr_Inq_CName" styleClass="body-fieldsTextFields" styleId="Scr_Inq_CName_id" tabindex="4" onkeypress="return CommonKeyPressIsAlpha(event);" /></td>
</tr>
For the CSS Rule, you can use attribute selectors:
input[type="text"]{
//This rule is valid for every input of type text, or textfield.
}
The two fields as I said should already be visible on same row.
精彩评论