[英]s:textfield alternative in struts2
When I click a button, values has to be displayed. 当我单击一个按钮时,必须显示值。 The displayed value should not be a textfield.
显示的值不应为文本字段。 Since I use the s:textfield tag, the textfield tag displays a text box while what I need is just a display portion without any textbox.
由于我使用s:textfield标记,因此textfield标记将显示一个文本框,而我所需要的只是一个没有任何文本框的显示部分。 Is there any way to avoid the editable textbox ?
有什么办法可以避免可编辑的文本框?
strHtml= '<s:textfield size="5"
name="p.pL['+pNo+'].reg['+cwNo+'].Div"
id="p.pL['+pNo+'].reg['+cwNo+'].Div" />';
td5.innerHTML=strHtml;
You may try using the s:div
as a container and use button to show on click. 您可以尝试使用
s:div
作为容器,并使用按钮在单击时显示。 The following code works: 以下代码有效:
Controller 控制者
import com.opensymphony.xwork2.ActionSupport;
public class TestAction extends ActionSupport {
private String myNonEditableValue = "This is a sample value";
public String getMyNonEditableValue() {
return this.myNonEditableValue;
}
public void setMyNonEditableValue(String myNonEditableValue) {
this.myNonEditableValue = myNonEditableValue;
}
public String execute() throws Exception {
return SUCCESS;
}
}
Page 页
<s:div id="myHiddenContent" cssStyle="display:none;"><s:text name="myNonEditableValue"></s:text></s:div>
<input type="button" value="Click to show" onclick="javascript:document.getElementById('myHiddenContent').style.display=''"/>
Rendered Source 渲染源
<div id="myHiddenContent"
style="display:none;"
>This is a sample value</div>
<input type="button" value="Click to show" onclick="javascript:document.getElementById('myHiddenContent').style.display=''"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.