簡體   English   中英

將 Html 字段轉換為 Struts2 標簽

[英]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??? 我的 html 頁面如下所示:

<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>

我已將樣式(style4)分配給 label“客戶名稱”,並將樣式(body-fieldsTextFields)分配給文本框,並且我已經對此進行了驗證。

當我使用 Struts-tag 時

它顯示應用了樣式(body-fieldsTextFields)的文本字段,當我運行項目時...但是客戶名稱label 顯示在單獨的行<tr><td>Customer name</td></tr>中。

文本字段顯示在下表行<tr>中。 我使用FireBug發現了這種疾病。

如何將style4應用於客戶名稱label 和body-fieldsTextFields樣式到所有文本字段,以及如何使 label 和文本字段顯示在同一行???????

謝謝..

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.

如果您更喜歡創建真正的 label,您可以這樣做(我使用的是 Struts 標簽):

<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>

對於 CSS 規則,您可以使用屬性選擇器:

input[type="text"]{
   //This rule is valid for every input of type text, or textfield.
}

正如我所說的,這兩個字段應該已經在同一行上可見。

<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>

這會給你你想要的

theme="simple"將刪除 struts 樣式。 cssClass屬性來使用 css 類。

也看看史蒂文的評論。你需要提高你的接受率。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM