我是新手,甚至是web应用程序...我想设置的属性strut表单bean使用jsp点击事件的按钮。但是我不能这样做......
以下是代码:
jsp代码
function importDistList(){
alert("Importing List function called...");
var val = document.forms['myForm'].importButtonClicked.value;
var val = document.forms['myForm'].elements['importButtonClicked'].value = "true";
alert("val :: "+val);
}
<console:button name="importMembers" script="importDistList();">
<console:label><bean:message key="com.demo.web.console.importList"/></console:label>
</console:button>
相反,它给出了错误消息:'document.forms.myForm.elements.import按钮点击'是空或不是一个对象
表单bean代码:
public class MyForm extends ActionForm {
private String importButtonClicked;
public void setImportButtonClicked(String importButtonClicked){
this.importButtonClicked = importButtonClicked;
}
public String getImportButtonClicked(){
return importButtonClicked;
}
}
struts配置。xml
<form-beans>
<form-bean name="myCSVForm" type="com.demo.web.console.MyCSVForm"/>
</form-beans>
<action-mappings>
<action path="/importCSV"
type="com.demo.web.console.MyCSVAction"
scope="session"
name="myForm"
input="/myCSV.jsp">
<forward name="success" path="/myDialog.jsp" />
</action>
</action-mappings>
在上面的jsp代码中,使用了自定义标记库,其代码为:
public class ButtonTag extends BodyTagSupport {
private static Log log = LogFactory.getLog(ButtonTag.class);
/**
* The name (id) of this button. This way you can
* retrieve it from some javascript and disable
* this button.
*/
private String name;
/**
* The "onClick" javascript.
*/
private String script;
/**
* The "href" value of the link.
*/
private String href;
/**
* If the button is enabled or not.
*/
private String enabled = "enabled";
/**
* cell attributes, allows for button placement
*/
private String cellattr;
/**
* the button has a popup attached to it.
*/
private String hasPopup = "false";
/**
* the button's only purpose is to display a pop up menu
*/
private String isPopupOnly = "false";
private String buttonLabel;
private String popupId = null;
public int doAfterBody() throws JspException {
if (href == null && script == null && !isButtonAPopupOnly()) {
throw new IllegalStateException("Either href or script parameter must be provided.");
}
try {
BodyContent bc = getBodyContent();
String content = bc.getString();
String buttonClass = null;
if (isEnabled()) {
buttonClass = "button";
}
else {
buttonClass = "buttonROLL_disabled";
}
/** cause sometimes the button is by itself or in a button bar */
if ( cellattr != null )
{
getPreviousOut().print("<td ");
getPreviousOut().print( cellattr );
getPreviousOut().print(">");
}
else
{
getPreviousOut().print("<td>");
}
/* getPreviousOut().print("<table cellSpacing=\"0\" cellPadding=\"0\" border=\"0\" id=\"" + name + "_table\"><tbody><tr><td>");
getPreviousOut().print("<table class=\"blackBorder\" cellSpacing=\"0\" cellPadding=\"0\" border=\"0\"><tbody><tr>");
getPreviousOut().print("<td class=\"");
*/
getPreviousOut().print("<table cellSpacing=\"0\" cellPadding=\"0\" border=\"0\" id=\"" + name + "_table\" class=\"blackBorder\">\n<tr>\n");
getPreviousOut().print("<td id=\"" + name + "\" nowrap");
getPreviousOut().print(" class=\"");
if (isEnabled()) {
getPreviousOut().print("button");
}
else {
getPreviousOut().print("button_disabled");
}
getPreviousOut().print("\"><a href=\"");
if ( isButtonAPopupOnly() )
{
getPreviousOut().print( "#" + popupId );
}
else if (script != null && href != null) {
getPreviousOut().print(href);
getPreviousOut().print("\" onclick=\"");
getPreviousOut().print(script);
}
else if (script != null) {
getPreviousOut().print("javascript:");
getPreviousOut().print(script);
}
else if ( href != null ){
getPreviousOut().print(href);
}
else {
getPreviousOut().print("#");
}
getPreviousOut().print("\" class=\"");
if (isEnabled()) {
getPreviousOut().print("buttonRoll");
}
else {
getPreviousOut().print("buttonRoll_disabled");
}
if ( isButtonAPopupOnly() )
{
getPreviousOut().print("\" id=\"");
getPreviousOut().print(name);
getPreviousOut().print("_label\">");
getPreviousOut().print( buttonLabel );
getPreviousOut().print( " <img src=\"images/i_sort_des.gif\" border=\"0\"/>" );
getPreviousOut().print("</a>");
getPreviousOut().print( content );
getPreviousOut().print("</td>\n");
}
else if ( buttonHasAPopup() )
{
getPreviousOut().print("\" target=\"_self\" id=\"");
getPreviousOut().print(name);
getPreviousOut().print("_label\">");
getPreviousOut().print( buttonLabel );
getPreviousOut().print("</a></td>\n");
getPreviousOut().print( "<td id=\" ");
getPreviousOut().print( name );
getPreviousOut().print("PopupButton nowrap class=\"button\"><a href=\"#" );
getPreviousOut().print( popupId );
getPreviousOut().print("'); class=\"buttonRoll\"><img src=\"images/i_sort_des.gif\" border=\"0\"></a>" );
getPreviousOut().print( content );
getPreviousOut().print( "</td>\n" );
}
else // a basic button
{
getPreviousOut().print("\" target=\"_self\" id=\"");
getPreviousOut().print(name);
getPreviousOut().print("_label\">");
getPreviousOut().print( buttonLabel );
getPreviousOut().print("</a></td>\n");
}
getPreviousOut().print("</tr></table></td>\n");
} catch (IOException e) {
e.printStackTrace();
throw new IllegalStateException("Error creating the page's HTML code.");
}
return SKIP_BODY;
}
public int doEndTag() throws JspException {
return EVAL_PAGE;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public String getPopupButtonName() {
if ( isButtonAPopupOnly() )
return name;
else
return name + "PopupButton";
}
public void setScript(String script) {
this.script = script;
}
public String getScript() {
return script;
}
public void setHref(String href) {
this.href = href;
}
public String getHref() {
return href;
}
public void setCellattr(String cellattr) {
this.cellattr = cellattr;
}
public String getCellattr() {
return cellattr;
}
public void setButtonEnabled(String enabled) {
this.enabled = enabled;
}
public String getButtonEnabled() {
return enabled;
}
public boolean isEnabled() {
return enabled.equals("enabled");
}
public void setIsPopupOnly(String isPopupOnly) {
this.isPopupOnly = isPopupOnly;
}
public String getIsPopupOnly() {
return isPopupOnly;
}
public boolean isButtonAPopupOnly() {
return isPopupOnly.equals("true");
}
public void setHasPopup(String hasPopup) {
this.hasPopup = hasPopup;
}
public String getHasPopup() {
return hasPopup;
}
public boolean buttonHasAPopup() {
return hasPopup.equals("true");
}
public void setButtonLabel(String buttonLabel) {
this.buttonLabel = buttonLabel;
}
public String getButtonLabel() {
return buttonLabel;
}
public void setPopupId(String popupId) {
if ( this.popupId == null)
this.popupId = popupId;
}
public String getPopupId() {
return popupId;
}
}
name=“myForm”
应该与formbean中的name=“myCSVForm”
相同
属性名称应与表单元素实体的名称相同
- 提交表单或使用(JSTL)
问题内容: 因此,我进行了一些研究,并在代码中将按钮定义为对象之后 这是我的问题 那你的活动… 问题: 当我输入“ this”时,它说: 我不知道为什么? 这是.java文件中的代码 问题答案: View中的SetOnClickListener(Android.View.view.OnClickListener)无法应用于(com.helloandroidstudio.MainActivity)
编辑:底部的解决方案 这是一个跳棋游戏。单击一个按钮后,它等待单击第二个按钮与之交换。然而,有时你可能不想移动那个按钮,但一旦你点击了它,就没有回头路了,因为我无法禁用它。 在这里的其他帖子中,我看到人们使用 这只是使它在第一次单击后不可见。 这什么都干不了。 这也没什么用。编辑:所有这些方法都用true和false进行了尝试。 私有无效交换(){ 但你也需要 这样它就重新启用了它,或者其他什么,
我想在单击JFrame标题栏的红色close按钮时调用一个方法。 我如何捕捉那个事件?
我是kotlin android的新手。我已经创建了回收站视图的适配器。但是我不能为每个回收站视图项目执行单击事件。我需要参考代码的解释。请帮我做这件事。提前谢谢。这是我的代码供您参考。
问题内容: 所以我有Button_1,当单击时,它将使用ajax请求一个新的button_2。两个按钮在我的jquery(document).ready上都有click事件,但是当按钮2添加到页面时,它没有jquery事件。那可能吗? 这是我的页面加载代码: 问题答案: 您必须在 DOM 上创建事件。 REF: http : //api.jquery.com/on/
上述代码来自网站,但是尽管尝试了多次尝试,我仍无法单击此按钮。我该怎么办? 如何使用c# selenium点击按钮?以上对我不起作用。