Dear ofbiz,
I would like to attach a file and check that by a java event. I have done that by the example module. https://weberp.dyndns-server.com:8443/example/control/main I have created the servlet page for the web and done some code in controller that call the java event, but my problem is that how the java file can read that attachment file? Here I also attached some of my code. Attache.ftl <form method="post" enctype="multipart/form-data" action="<@ofbizUrl>AttacheUpload</@ofbizUrl>"> <table cellspacing="0" class="basic-table"> <input type="file" size="50" name="fname"> <input type="submit" class="smallSubmit" value="${uiLabelMap.ProductUploadImage}"> </table> </form> controller.xml <request-map uri="AttacheUpload"> <security https="true" auth="true"/> <event type="java" path="com.mano.license.servlet.AttacheServlet" invoke="doPost"/> <response name="success" type="view" value="AttacheChecker"/> </request-map> <view-map name="main" type="screen" page="component://example/widget/example/AttacheScreens.xml#main"/> build.xml <fileset dir="../../framework/base/lib/j2eespecs" includes="*.jar"/> <fileset dir="../../hot-deploy/example/lib" includes="*.jar"/> AttacheScreens.xml <decorator-section name="body"> <platform-specific> <html> <html-template location="component://example/webapp/example/Attache/Attache.ftl"/> </html> </platform-specific> </decorator-section> Seem I can call the java file but I am not sure how can I write the java code to read that attached file. AttachServlet.java package com.mano.Attach.servlet; import java.io.Closeable; import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.oreilly.servlet.MultipartWrapper; import de.schlichtherle.Attach.AttachContent; import de.schlichtherle.Attach.AttachManager; import com.mano.Attach.service.AttachUtil; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.cache.UtilCache; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.security.Security; import org.ofbiz.base.util.UtilDateTime; // import org.ofbiz.base.util.UtilParse; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.entity.GenericPK; import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.transaction.GenericTransactionException; import org.ofbiz.entity.transaction.TransactionUtil; import org.ofbiz.entity.util.EntityListIterator; import org.ofbiz.entity.util.EntityUtil; //import org.ofbiz.product.store.ProductStoreWorker; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; /** * Servlet for installing Attach. * * @author Manohar Viswanathan */ public class AttachServlet extends HttpServlet { private static final long serialVersionUID = 1L; // @Override public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException { LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher"); GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); //PrintWriter out = null; try { System.out.println("testing"); MultipartWrapper multipart = ((MultipartWrapper) request); File AttachFile = multipart.getFile("AttachFile"); AttachManager lm = new AttachManager(AttachUtil.licenceParam); lm.install(AttachFile); AttachContent lc = lm.verify(); System.out.println("AttachServlet:: Attach valid till " + lc.getNotAfter()); response.setContentType("text/html"); out = response.getWriter(); out.println("New Attach installed. <a href='Attach.jsp'>Continue</a>"); } catch (Exception e) { throw new ServletException(e); } finally { close(out); } } //Utility method private void close(Closeable closer) { if (closer != null) { try { closer.close(); } catch (IOException ignore) { } } } } Looking for your reply Yours, Ivan |
if I understand you are asking about fileupload
take a look at the code for uploading an image in the catatlog->product->content ========================= BJ Freeman Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=52> Specialtymarket.com <http://www.specialtymarket.com/> Systems Integrator-- Glad to Assist Chat Y! messenger: bjfr33man Fai Kwong sent the following on 9/23/2010 9:14 PM: > > Dear ofbiz, > > I would like to attach a file and check that by a java event. I have done that by the example module. > > https://weberp.dyndns-server.com:8443/example/control/main > > I have created the servlet page for the web and done some code in controller that call the java event, but my problem is that how the java file can read that attachment file? > > Here I also attached some of my code. > |
Administrator
|
Fai Kwong,
Beware you were sending your email to [hidden email] [hidden email] [hidden email] [hidden email] [hidden email] [hidden email] [hidden email] I guess you wanted only [hidden email] Please check https://cwiki.apache.org/confluence/display/OFBADMIN/Mailing+Lists Jacques From: "BJ Freeman" <[hidden email]> > if I understand you are asking about fileupload > take a look at the code for uploading an image in the catatlog->product->content > > > ========================= > BJ Freeman > Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=52> > Specialtymarket.com <http://www.specialtymarket.com/> > Systems Integrator-- Glad to Assist > > Chat Y! messenger: bjfr33man > Fai Kwong sent the following on 9/23/2010 9:14 PM: > > >> >> Dear ofbiz, >> >> I would like to attach a file and check that by a java event. I have done that by the example module. >> >> https://weberp.dyndns-server.com:8443/example/control/main >> >> I have created the servlet page for the web and done some code in controller that call the java event, but my problem is that how >> the java file can read that attachment file? >> >> Here I also attached some of my code. >> > |
Hi Fai Kwong,
If you want to upload a file, No need to write code for uploading its already present there in OFBiz framework. You can also see functionality of uploading in party component. Create a new party(person/customer) you can see section 'Party Content' for browse and uploading file. Just you have to select purpose & mime/type. If you want to update click on link of party content created (say 10010). It takes you to the Parties/PARTY CONTENT tab there you can Edit & upload another file. Code flow can be started from 'createPartyContent' request in party controller. There is a simple method 'createPartyContent' in component://party/script/org/ofbiz/party/party/PartySimpleEvents.xml file which internally calls uploadImageAndParameters() method of class 'org.ofbiz.content.layout.LayoutWorker' which converts file into byte arrray, then it calls service 'createPartyContent' which upload byte array of the file to the Database. You just need to go through the code. That can help you. --- Thanks & Regards, Pankaj Savita Mob: 09890262476 Email: [hidden email]<http://redir.aspx/?C=172aa0592ccc4a40a7119b8b86b626f8&URL=mailto%3apankajsavita%40gmail.com> On Fri, Sep 24, 2010 at 11:31 AM, Jacques Le Roux < [hidden email]> wrote: > Fai Kwong, > > Beware you were sending your email to > [hidden email] > [hidden email] > [hidden email] > [hidden email] > [hidden email] > [hidden email] > [hidden email] > > I guess you wanted only [hidden email] > Please check > https://cwiki.apache.org/confluence/display/OFBADMIN/Mailing+Lists > > Jacques > > From: "BJ Freeman" <[hidden email]> > > if I understand you are asking about fileupload >> take a look at the code for uploading an image in the >> catatlog->product->content >> >> >> ========================= >> BJ Freeman >> Strategic Power Office with Supplier Automation < >> http://www.businessesnetwork.com/automation/viewforum.php?f=52> >> Specialtymarket.com <http://www.specialtymarket.com/> >> Systems Integrator-- Glad to Assist >> >> Chat Y! messenger: bjfr33man >> Fai Kwong sent the following on 9/23/2010 9:14 PM: >> >> >> >>> Dear ofbiz, >>> >>> I would like to attach a file and check that by a java event. I have done >>> that by the example module. >>> >>> https://weberp.dyndns-server.com:8443/example/control/main >>> >>> I have created the servlet page for the web and done some code in >>> controller that call the java event, but my problem is that how the java >>> file can read that attachment file? >>> >>> Here I also attached some of my code. >>> >>> >> > > |
Free forum by Nabble | Edit this page |