Jibin Najeeb

Greenhorn
+ Follow
since Nov 27, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jibin Najeeb

Can I Upload file without using enctype

<s:form method="post" enctype="multipart/form-data" theme="simple">
</s:form>

I want to upload file without using those enctype in forms. IS IT POSSIBLE?
7 years ago
The file contains so many fields. Im only showing some of them
<s:form action="buildCompany" method="post" enctype="multipart/form-data" theme="simple">
<s:textfield name="companyName" />// I only applied validation for this field only.
....
...
..
<s:file cssClass="input-file" label="" name="myFile" size="19" cssStyle="opacity: 0;" />
...
..
<button class="btn btn-inverse"><i class="white-icons download_to_computer"></i>Save</button>//<s:submit>also tried
</s:form>

My Action Class is this

public class CreateCompany extends ActionSupport {
String companyName;
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
@Override
public String execute() throws Exception {
System.out.println("from execute"+companyName);
return SUCCESS;
}
@Override
public void validate() {
if ((companyName == null) || companyName.length() == 0) {
this.addFieldError("companyName", "BLank");
}
}
}

my struts.xml

<package name="my-default" extends="struts-default">
<action name="buildCompany" class="com.mt.erp.CreateCompany">
<result name="success" type="redirect-action">redirection</result>
<result name="error" type="redirect-action">error</result>
<result name="input">Test.jsp</result>
</action>
<action name="redirection" class="com.mt.erp.Redirection">
<result name="success">success.jsp</result>
<result name="input">Test.jsp</result>
</action>

The problem is the validation some times shows error even when it is not empty. Some times work properly. The causing is randomly. Why is this
Is there any issue between enctype and struts 2 validation
7 years ago
Question 1: Is there any method to short circuit the validation for each field in void validation method not in xml config.

Question 2: I am using a double valued text field. My validation is
<field name="amount">
<field-validator type="double" >
<param name="minInclusive">100</param>
<param name="maxInclusive">10000000000</param>
<message key="amount.error">
</message>
</field-validator>
</field>
The problem is whenever I type a character in the text field for eg:- abc. The text field showing error like this
""""Invalid Field Value For Amount""" and
""" amount.error"""

I only want to display the first erro when I type a character and not the second one. How to do? . I think the field cannot be manually coded for Invalid character . Not Sure Though. Any help appreciated Thanks
7 years ago
I need to use the above code for two fields.
<s:form theme="simple" >
<s:if test=hasFieldErrors()">
<div class="errorMessage">Enter Bank Account</div><br>
</s:if>
<s:textfield name="bankaccount" cssClass="input-xlarge text-tip" id="input01" title="Bank account"/>
<s:if test="hasFieldErrors()">
<div class="errorMessage">Amount Problem</div><br>
</s:if>
<s:textfield name="amount" cssClass="input-xlarge text-tip" id="input01" title="Amount"/>
</s:form>
Note:Theme is simple

The validate function in the action class is

public void validate(){
if((bankaccount==null)||bankaccount.length()==0){
this.addFieldError("bankaccount", "ERROR bank");
}
if((amount==0.0)){
this.addFieldError("Amount", "ERROR amount");
}

}

The problem is whenever there is a field error in any one of the two field. The validation message corresponding to each is displayed for two fields.
ie ""Error bank"" above bank account field and ""ERROR amount"" above amount field.

I need to work the validation like that worked in default form theme. Any Help Appreciated..
7 years ago
The following code
<s:form>
<s:textfield name="username" label="Username"/>
</s:form>

generates the follwing html code

<table>
<tr>
<td class="tdLabel"><label for="login_username" class="label">Username:</label></td>
<td><input type="text" name="username" value="" id="login_username"/>
</td>
</tr>
</table>

I want to change the value of label class--- class="label" which is default. Is there any method with default theme as xhtml..
7 years ago
Hey all,
I am new in struts. I want to display validated error messages above each and every field. The default <s:form> is generating a table automatically. So Design is changing. So i have to keep it in simple theme. But also i wanna show Validation errors for each field without affect design.. Is there any way to change the form theme for validation manually. Please HeLp..
7 years ago