I have to invoke a post method of a Form at a particular URL
from my current program
I am doing the following
I am invoking this method in actionPerformed method of my button
public void formSubmitted(FormEvent event) {
FormEncodedContent content = (FormEncodedContent) event.getContent();
FormURLEncodedContent encodedContent = new FormURLEncodedContent();
String selectedValue = content.getValue("RadioGroup1").toString();
System.out.println("Form encoded content:" + event.getContent());
System.out.println("Value of radio button" + selectedValue);
if (selectedValue.equalsIgnoreCase("DSL")) {
configFile = "DSLProperties.txt";
}
else if (selectedValue.equalsIgnoreCase("Cable")) {
configFile = "CableProperties.txt";
}
loadConfiguration(encodedContent, configFile);
postForm(encodedContent);
}
which calls the following method
public void postForm(FormURLEncodedContent content) {
try {
File f = new File(System.getProperty("user.home") + File.separator +
".spark" + File.separator + "templates" +
File.separator + "NetworkConfig.htm");
uriResource = new URIResource(f.toURL(), content.toString());
System.out.println("contents are" + content.toString());
}
catch (MalformedURLException mex) {
System.out.println("Malformed URL" + mex.getMessage());
}
catch (IOException mex) {
System.out.println(mex.getMessage());
}
FormEncodedContent is in form of a stringbuffer and I am trying to send this content through uriResource class but I am not able to perform this operation.Can anyone pls suggest me where I am going wrong or what should be my approach?
Thankx in advance
from my current program
I am doing the following
I am invoking this method in actionPerformed method of my button
public void formSubmitted(FormEvent event) {
FormEncodedContent content = (FormEncodedContent) event.getContent();
FormURLEncodedContent encodedContent = new FormURLEncodedContent();
String selectedValue = content.getValue("RadioGroup1").toString();
System.out.println("Form encoded content:" + event.getContent());
System.out.println("Value of radio button" + selectedValue);
if (selectedValue.equalsIgnoreCase("DSL")) {
configFile = "DSLProperties.txt";
}
else if (selectedValue.equalsIgnoreCase("Cable")) {
configFile = "CableProperties.txt";
}
loadConfiguration(encodedContent, configFile);
postForm(encodedContent);
}
which calls the following method
public void postForm(FormURLEncodedContent content) {
try {
File f = new File(System.getProperty("user.home") + File.separator +
".spark" + File.separator + "templates" +
File.separator + "NetworkConfig.htm");
uriResource = new URIResource(f.toURL(), content.toString());
System.out.println("contents are" + content.toString());
}
catch (MalformedURLException mex) {
System.out.println("Malformed URL" + mex.getMessage());
}
catch (IOException mex) {
System.out.println(mex.getMessage());
}
FormEncodedContent is in form of a stringbuffer and I am trying to send this content through uriResource class but I am not able to perform this operation.Can anyone pls suggest me where I am going wrong or what should be my approach?
Thankx in advance