File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes >html:text < default value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "&gt;html:text &lt; default value" Watch "&gt;html:text &lt; default value" New topic
Author

&gt;html:text &lt; default value

ramandeep singh
Greenhorn

Joined: Jan 16, 2007
Posts: 13
i have entered the default value ,value="91" in the the form
and when i submit the form with the changes in text value like i change
text to 333
but submit.do still shows the value as 91 wht should i do

>html:text style="width:32px" maxlength="5" property="homecountry" value="91"/<
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
It seems like what you have should work. Are you positive that you form has a public method named setHomecountry (with this exact capitalization)? If you don't get any help then posting more of your form, jsp and action code might point out the problem.

- Brent
Chris Boldon
Ranch Hand

Joined: Aug 10, 2006
Posts: 190
value=91. So everytime the field is not null the value will be 91? Use struts to prepopulate via forms.
[ January 16, 2007: Message edited by: Chris Boldon ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
My recommendation is that you not use the "value" attribute at all. As Chris pointed out, the best way to set a default value in Struts is to set the property in the ActionForm.

In this case, I'd put the following statement in the Action that forwards to this JSP and leave out the value attribute:

myForm.setHomeCountry("91");


Merrill
Consultant, Sima Solutions
ramandeep singh
Greenhorn

Joined: Jan 16, 2007
Posts: 13
hi thank you for reply
i am sending you my code
i tried public method named setHomecountry (with this exact capitalization)
but its giving the same result

i am sending you the form and actionForm

==========================================================
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<html:html>
<html:form action="/Submit" enctype="multipart/form-data" >
<TABLE id="Table1" width="550">
<TBODY>
<TR align="left" height="25">
<TD class="tableheader" colSpan="3">  <bean:message key="common.required"/></B></TD>
</TR>
<TR class="tableheader" align="center" height="25">
<TD width="5%" bgColor="#cccc99"><bean:message key="common.sno"/></TD>
<TD bgColor="#cccc99" colSpan="2"><bean:message key="resume.details"/></TD>
</TR>
<TR class="bodytext" vAlign="top" height="25">
<TD class="tableheader" align="center" width="5%" bgColor="#cccc99">1.</TD>
<TD width="45%" bgColor="#ebebe1" align="left"><bean:message key="resume.coordname"/><html:errors property="coordname"/></TD>
<TD width="50%" bgColor="#ebebe1"><html:text style="WIDTH: 240px; HEIGHT: 22px" property="coordname" /></TD>
</TR>
<TR class="bodytext" vAlign="top" height="25">
<TD class="tableheader" align="center" width="5%" bgColor="#cccc99">2.</TD>
<TD width="45%" bgColor="#ebebe1" align="left"><bean:message key="resume.email"/><html:errors property="email"/></TD>
<TD width="50%" bgColor="#ebebe1"><html:text style="WIDTH: 240px; HEIGHT: 22px" property="email" /></TD>
</TR>
<TR class="bodytext" height="25">
<TD class="tableheader" align="center" width="5%" bgColor="#cccc99">3.</TD>
<TD width="45%" bgColor="#ebebe1" align="left"><bean:message key="resume.tele"/></TD>
<TD width="50%" bgColor="#ebebe1"></TD>

<TR class="bodytext" height="25">
<TD class="tableheader" align="center" width="5%" bgColor="#cccc99" rowSpan="3"></TD>
<TD align="left" width="45%" bgColor="#ebebe1"><bean:message key="resume.home"/>
<html:errors property="home"/><html:errors property="homecountry"/><html:errors property="homestd"/></TD>
<TD align="center" width="50%" bgColor="#ebebe1">+<html:text style="width:32px" maxlength="5" property="homecountry" value="91"/>  
<html:text style="width:32px" maxlength="5" property="homestd" />  
<html:text style="width:141px" maxlength="15" property="home"/></TD>
</TR>
<TR class="bodytext" height="25">
<!--<TD class="tableheader" align="center" width="5%" bgColor="#cccc99" ></TD>-->
<TD align="left" width="45%" bgColor="#ebebe1"><bean:message key="resume.office"/><html:errors property="office"/><html:errors property="officecountry"/><html:errors property="officestd"/></TD>
<TD align="center" width="50%" bgColor="#ebebe1">+<html:text style="width:32px" maxlength="5" property="officecountry" value="91"/>  
<html:text style="width:32px" maxlength="5" property="officestd" />  
<html:text style="width:141px" maxlength="15" property="office"/></TD>
</TR>
<TR class="bodytext" height="25">
<TD align="left"width="45%" bgColor="#ebebe1"><bean:message key="resume.mobile"/><html:errors property="mobile"/><html:errors property="mobilecountry"/></TD>
<TD align="center" width="50%" bgColor="#ebebe1">+<html:text style="width:32px" maxlength="5" property="mobilecountry" value="91"/>  <html:text style="width:188px" maxlength="15" property="mobile"/></TD>
</TR>
<TR class="bodytext" height="25">
<TD class="tableheader" align="center" width="5%" bgColor="#cccc99" ></TD>
<TD align="left" width="45%" bgColor="#ebebe1"><bean:message key="resume.fax"/><html:errors property="fax"/><html:errors property="faxcountry"/><html:errors property="faxstd"/></TD>
<TD align="center" width="50%" bgColor="#ebebe1">+<html:text style="width:32px" maxlength="5" property="faxcountry" value="91"/>  
<html:text style="width:32px" maxlength="5" property="faxstd" />  
<html:text style="width:141px" maxlength="15" property="fax"/></TD>
</TR>





<TR class="bodytext" vAlign="top" height="25">
<TD class="tableheader" align="left" width="25" bgColor="#cccc99">5.</TD>
<TD width="280" bgColor="#ebebe1" align="left"><bean:message key="resume.page"/><html:errors property="page"/></TD>
<TD align="center" width="280" bgColor="#ebebe1"><html:text style="WIDTH: 240px; HEIGHT: 22px" property="page" />
</TD>
</TR>
<TR class="bodytext" vAlign="top" height="25">
<TD class="tableheader" align="left" width="25" bgColor="#cccc99">6.</TD>
<TD width="280" bgColor="#ebebe1" align="left"><bean:message key="resume.brief"/><html:errors property="brief"/>
</TD>
<TD align="center" width="280" bgColor="#ebebe1"><html:textarea style="WIDTH: 240px; HEIGHT: 38px" rows="2" cols="27" property="brief" ></html:textarea> </TD>
</TR>
<TR class="bodytext" vAlign="top" height="25">
<TD class="tableheader" align="left" width="25" bgColor="#cccc99">7.</TD>
<TD width="280" bgColor="#ebebe1" align="left"><bean:message key="resume.noofphd"/><html:errors property="noofphd"/></TD>
<TD align="center" width="280" bgColor="#ebebe1"> <html:text style="WIDTH: 240px; HEIGHT: 22px" property="noofphd" />
</TD>
</TR>
<TR class="bodytext" vAlign="top" height="25">
<TD class="tableheader" align="left" width="25" bgColor="#cccc99">8.</TD>
<TD width="280" bgColor="#ebebe1" align="left"><bean:message key="resume.publication"/><html:errors property="publication"/></TD>
<TD align="center" width="280" bgColor="#ebebe1"> <html:textarea style="WIDTH: 240px; HEIGHT: 38px" rows="2" cols="27" property="publication" ></html:textarea>
</TD>
</TR>
<TR class="bodytext" vAlign="top" height="25">
<TD class="tableheader" align="left" width="25" bgColor="#cccc99">9.</TD>
<TD width="280" bgColor="#ebebe1" align="left"><bean:message key="resume.pic"/><html:errors property="pic"/></TD>
<TD align="center" width="280" bgColor="#ebebe1"><html:file style="WIDTH: 240px; HEIGHT: 22px"property="pic" />

</TD>
</TR>
<TR class="bodytext" vAlign="top" height="25">
<TD class="tableheader" align="left" width="25" bgColor="#cccc99">10.</TD>
<TD width="280" bgColor="#ebebe1" align="left"><bean:message key="resume.resume"/><html:errors property="resume"/></TD>
<TD align="center" width="280" bgColor="#ebebe1"><html:file style="WIDTH: 240px; HEIGHT: 22px" property="resume" /> </TD>
</TR>
<TR class="bodytext" vAlign="top" height="25">
<TD class="tableheader" align="left" width="25" bgColor="#cccc99">11.</TD>
<TD width="280" bgColor="#ebebe1" align="left"><bean:message key="resume.faculties"/><html:errors property="faculties"/></TD>
<TD align="center" width="280" bgColor="#ebebe1"><html:text style="WIDTH: 240px; HEIGHT: 22px" property="faculties" />

</TD>
</TR>
<TR align="center" height="25">
<TD class="tableheader" bgColor="#cccc99" colSpan="3"><html:submit styleClass="tableheader" />    <html:reset styleClass="tableheader"/>
</TD>
</TR>
</TABLE>
</html:form>

</html:html>

=================================================================

actionform

package submit.resume;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.upload.FormFile;
public class SubmitResumeActionForm extends org.apache.struts.validator.ValidatorForm {

private String coordname;
private String email;
private String office;
private String officecountry;
private String officestd;
private String home;
private String homecountry="91";
private String homestd;
private String mobile;
private String mobilecountry;
private String fax;
private String faxcountry;
private String faxstd;
private String page;
private String brief;
private String noofphd;
private String publication;
private FormFile pic;
private FormFile resume;
private String faculties;
public SubmitResumeActionForm() {
super();

}
public String getcoordname() {
return coordname;
}

public String getemail() {
return email;
}

public String gethome() {
return home;
}
public String gethomecountry() {
return homecountry;
}
public String gethomestd() {
return homestd;
}
public String getoffice() {
return office;
}
public String getofficecountry() {
return officecountry;
}

public String getofficestd() {
return officestd;
}


public String getmobile() {
return mobile;
}


public String getmobilecountry() {
return mobilecountry;
}
public String getfax() {
return fax;
}
public String getfaxcountry() {
return faxcountry;
}
public String getfaxstd() {
return faxstd;
}

public String getpage() {
return page;
}
public String getbrief() {
return brief;
}

public String getfaculties() {
return faculties;
}

public String getnoofphd() {
return noofphd;
}

public FormFile getpic() {
return pic;
}

public String getpublication() {
return publication;
}

public FormFile getresume() {
return resume;
}



public void setbrief(String brief) {
this.brief = brief;
}

public void setcoordname(String coordname) {
this.coordname = coordname;
}

public void setemail(String email) {
this.email = email;
}

public void setfaculties(String faculties) {
this.faculties = faculties;
}

public void setfax(String fax) {
this.fax = fax;
}
public void setfaxstd(String fax) {
this.faxstd = fax;
}
public void setfaxcountry(String fax) {
this.faxcountry = fax;
}

public void sethome(String home) {
this.home = home;
}
public void sethomestd(String home) {
this.homestd = home;
}
public void sethomecountry(String home) {
this.homecountry = home;
}

public void setmobile(String mobile) {
this.mobile = mobile;
}
public void setmobilecountry(String mobile) {
this.mobilecountry = mobile;
}
public void setoffice(String office) {
this.office = office;
}
public void setofficestd(String office) {
this.officestd = office;
}
public void setofficecountry(String office) {
this.officecountry = office;
}
public void setnoofphd(String noofphd) {
this.noofphd = noofphd;
}



public void setpage(String page) {
this.page = page;
}

public void setpic(FormFile pic) {
this.pic = pic;
}

public void setpublication(String publication) {
this.publication = publication;
}

public void setresume(FormFile resume) {
this.resume = resume;
}






public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {

ActionErrors errors = super.validate(mapping, request);


if (getpic() == null || getpic().getFileSize() <=200) {
System.out.println(getpic());
if(getpic().getFileSize()==0) {
errors.add("pic", new ActionMessage("errors.resume.emptyfile"));
}else {
errors.add("pic", new ActionMessage("errors.resume.filesize","200"));}

}else if(!(getpic().getFileName().endsWith(".jpeg")||getpic().getFileName().endsWith(".gif")||getpic().getFileName().endsWith(".png"))) {
errors.add("pic", new ActionMessage("errors.resume.picfiletype"));
}

if (getresume() == null || getresume().getFileSize() <= 1000) {
if(getresume().getFileSize()==0 ) {
errors.add("resume", new ActionMessage("errors.resume.emptyfile"));
}else {
errors.add("resume", new ActionMessage("errors.resume.filesize","1000"));
}
}else if(!(getresume().getFileName().endsWith(".doc")||getresume().getFileName().endsWith(".rtf")))
{ errors.add("resume", new ActionMessage("errors.resume.resumefiletype"));
}

System.out.println(getresume().getFileName().endsWith(".doc")+" "+getresume().getFileName().endsWith(".rtf"));
return errors;
}

public void reset(ActionMapping mapping,HttpServletRequest request) {
coordname="";
email="";
office="";
home="";
mobile="";
fax="";
page="";
brief="";
noofphd="";
publication="";
pic=null;
resume=null;
faculties="";
officecountry="";
officestd="";
homecountry="91";
homestd="";
mobilecountry="";
faxcountry="";
faxstd="";
}

}
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
As I said in my previous post, remove the value attribute entirely from the <html:text> tag. If the value attribute is present, the property will revert to that value if there is a validation error and the page is redisplayed. Since an <html:text> tag is already tied to the value of the ActionForm property, the value attribute should seldom if ever be used.
ramandeep singh
Greenhorn

Joined: Jan 16, 2007
Posts: 13
ok i will do tht
but i dont have any other action pages linked to this page at the moment
so is there any other way out
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I see that you've set the value of homecountry to 91 in the reset method of your ActionForm. That will suffice. With that in place, you don't need to set the value in an Action class.
ramandeep singh
Greenhorn

Joined: Jan 16, 2007
Posts: 13
thank you for the help ,it is working now worked
i really appreciate your help
and i will seek your help in the future
prashant kond
Greenhorn

Joined: Mar 03, 2005
Posts: 18
Hi,
If you see the topic for this post it is looking weird. Actually it might have posted like <html:text and it got printed in differently.
It is not allowing &,< and > charecters as input.
I am facing same problem in my UI page. From UI to form it is converting in differently.
If any one having solution to get rid of this would be greatful.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: &gt;html:text &lt; default value