You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Desbuquoit Benjamin <be...@hotmail.com> on 2003/04/22 18:34:11 UTC
interaction between .Java and .VM
Hello,
I would like to generate a dynamic form ( from a text file. 1 line <=> 1 input type text )
- i read a text file
- i generate the html code to create the form
- i use HttpServletResponse to send this code to the user screen
but i don't know how to access to the file.java from my Menu.vm ?
where do i put the file.java ?? into the "actions" directory or into the "screens" directory ?
i'm using Turbine and Velocity under Linux RedHat 7.3
here is my Menu.vm :
<font face="$ui.sansSerifFonts">
<a href="$link.setPage("Insert.vm")">Insert Entry</a>
<p>
<a href="$link.setAction("GenerateForm")">Generate Form Dyn</a>
<p>
<b>Flux</b>
<br>
<a href="$link.setPage("user,FluxUserList.vm")">Users</a>
<br>
<a href="$link.setPage("group,FluxGroupList.vm")">Groups</a>
<br>
<a href="$link.setPage("role,FluxRoleList.vm")">Roles</a>
<br>
<a href="$link.setPage("permission,FluxPermissionList.vm")">Permissions</a>
<p>
<a href="$link.setPage("Index.vm")">Home</a>
<p>
<a href="$link.setAction("LogoutUser")">Logout</a>
</font>
here is my GenerateForm.java :
public class GenerateForm extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("<HTML>");
out.println("<HEAD><TITLE>This is the title</TITLE></HEAD");
out.println("<BODY>");
out.println("<br> <form method='post' enctype='multipart/form-data' action=$link.setPage('Index.vm').setAction('ADDDCM')>");
out.println("<input type='submit' value='Send' name='eventSubmit_doAjout'>");
FileReader fileReader = null;
BufferedReader bufferedReader = null;
String initial = null;
StringTokenizer st = null;
String val1 = null;
String val2 = null;
String val3 = null;
try {
fileReader = new FileReader("./configuration/addMammo.config");
bufferedReader = new BufferedReader(fileReader);
initial = bufferedReader.readLine();
System.out.println(initial);
st = new StringTokenizer(initial,"||");
val1 = st.nextToken();
val2 = st.nextToken();
val3 = st.nextToken();
out.println(val2 + "<input type='text' value='"+val3+"' name='"+val1+"'> ");
out.println("<BR>");
initial = bufferedReader.readLine();
}
catch(FileNotFoundException ignored)
{ }
catch(IOException ignored) { }
while(initial != null) {
try {
st = new StringTokenizer(initial,"||");
val1 = st.nextToken();
val2 = st.nextToken();
val3 = st.nextToken();
out.println(val2+"<input type='text' value='"+val3+"' name='"+val1+"'> ");
out.println("<BR>");
initial = bufferedReader.readLine();
}
catch(FileNotFoundException ignored) { }
catch(IOException ignored) { }
}
// close the file
try {
if(bufferedReader != null)
{
out.println("</form>");
bufferedReader.close();
}
}
catch(IOException ignored) { }
}
}
where can i find some exemples of "interaction" between .java and .vm ???
if you have some exemples, you can send this to bk394206@skynet.be
thank you...
Benj