SoFunction
Updated on 2025-04-14

flex handwritten online signature implementation code page 2/2


/**
*
*/
package ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
/**
* @author presses
*
*/
@SuppressWarnings ( "serial" )
public class PictureServlet extends AutoMapperServlet {
private Logger log=( this .getClass().getName());
/**
* test
*/
@Action ( "sayHi" )
public void sayHi(HttpServletRequest req, HttpServletResponse res) throws IOException {
(res, "hi" , null );
}
/**
* Save the picture
*/
@Action ( "savePic" )
public void savePic(HttpServletRequest req, HttpServletResponse res) throws IOException {
String name= ServletUtil
.getStringParameterWithTrim(req, "name" );
if (name== null ){
name="Signature.jpg" ;
}
Picture pic = new Picture((req, "module" ),name, new Blob((())));
new PictureService().savePic(pic);
("Save file size:" +().getBytes().length);
(res, ());
}
/**
* Find all pictures
*/
@Action ( "queryAllPic" )
public void queryAllPic(HttpServletRequest req, HttpServletResponse res) throws IOException {
String result = "" ;
for (Picture pic : new PictureService().queryAllPicture()) {
if (() == null ) {
continue ;
}
result += new String(().getBytes(), "utf-8" ) + ":" ;
}
(res, result);
}
/**
* Get the picture by ID
*/
@Action ( "queryPicById" )
public void queryPicById(HttpServletRequest req, HttpServletResponse res) throws IOException {
String id = (req, "pid" );
("Start download the file, ID:" +id);
Picture pic = new PictureService().queryPicById((id));
("Downloaded file size:" +().getBytes().length);
(res, ().getBytes(), ());
}
}
/**
*
*/
package ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
/**
* @author presses
*
*/
@SuppressWarnings("serial")
public class PictureServlet extends AutoMapperServlet {
private Logger log=(().getName());
    /**
* test
     */
    @Action("sayHi")
    public void sayHi(HttpServletRequest req, HttpServletResponse res) throws IOException {
        (res, "hi", null);
    }
    /**
* Save the picture
     */
    @Action("savePic")
    public void savePic(HttpServletRequest req, HttpServletResponse res) throws IOException {
String name= ServletUtil
.getStringParameterWithTrim(req, "name");
if(name==null){
name="Signature.jpg";
}
        Picture pic = new Picture((req, "module"),name, new Blob((())));
        new PictureService().savePic(pic);
("Save file size: "+().getBytes().length);
        (res, ());
    }
    /**
* Find all pictures
     */
    @Action("queryAllPic")
    public void queryAllPic(HttpServletRequest req, HttpServletResponse res) throws IOException {
        String result = "";
        for (Picture pic : new PictureService().queryAllPicture()) {
            if (() == null) {
                continue;
            }
            result += new String(().getBytes(), "utf-8") + ":";
        }
        (res, result);
    }
    /**
* Get the picture by ID
     */
    @Action("queryPicById")
    public void queryPicById(HttpServletRequest req, HttpServletResponse res) throws IOException {
        String id = (req, "pid");
("Start downloading of the file, ID:"+id);
        Picture pic = new PictureService().queryPicById((id));
("Downloaded file size: "+().getBytes().length);
        (res, ().getBytes(), ());
    }
}