Reputation: 1903
I am doing on Java Struts 2 framework.
Normally, I can get data from my JSP through the get set method in Form.java
(action class). Below is my example :
In main.jsp
file:
<html:text property="campaignName" size="50" maxlength="50" />
Thus, I can get this textbox name by getter and setter methods in the action class, the below is code from
mainForm.java
:
private String campaignName = null;
public String getCampaignName() {
return campaignName;
}
public void setCampaignName(String campaignName) {
this.campaignName = campaignName;
}
However, because of I want to use jQuery to do something, I no longer use <html:text>
as text box, but I use <input type="text" id="datepicker" />
.
Because of without property attribute inside this text box, I cant get the value from this text box. I have tried to add property="something"
inside the text box also, but get set method in mainForm.java
is return null
.
I would like to ask, how can I get the value by this text box?
Upvotes: 0
Views: 3431
Reputation: 1
The simple usage of that textbox is to use <s:textfield>
tag.
<s:textfield name="campaignName" size="50" maxlength="50" />
Upvotes: 1
Reputation: 45456
You can use <s:textfield name="campaignName" size="50" maxlength="50" />
and add struts tag to your jsp ( at the top ):
<%@ taglib prefix="s" uri="/struts-tags"%>
Upvotes: 1
Reputation: 40318
<s:textfield name="campaignName" size="50" maxlength="50" />
or
<input type="text" name="campaignName" size="50" maxlength="50" />
The name need to be matched with the field name
Upvotes: 1