IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Customize adding of files using Temp. Attachment Provider

  • 1.  Customize adding of files using Temp. Attachment Provider

    Posted Wed January 05, 2011 09:42 PM

    Hi everybody,
    I want to restrict users to add only one file with the same name.
    I am using Temporary Attachment Provider.
    Do anyone know how to do it?

    Regards,

    Marcelo


    #webMethods
    #MWS-CAF-Task-Engine
    #webMethods-BPMS


  • 2.  RE: Customize adding of files using Temp. Attachment Provider

    Posted Wed January 05, 2011 10:22 PM

    In 8.x, after you drop the Attachments List Control onto the canvas, you can right click and “Customize” that control which will decompose the control into all the Dialogs and other controls. This is useful for many types of customization, but i’m not sure it will solve your scenario.

    The browser won’t allow you to script anything to do with file input controls (Major Security Hole), so your validation will have to be done on the server side. I’d recommend adapting the sample provided with this thread: http://tech.forums.softwareag.com/viewtopic.php?p=67769#67769&sid=fdb0962e6440d5c954575304270fc2c0

    and add your validation to the server side.

    Regards,
    –mark


    #webMethods
    #webMethods-BPMS
    #MWS-CAF-Task-Engine


  • 3.  RE: Customize adding of files using Temp. Attachment Provider

    Posted Fri January 07, 2011 07:06 PM

    Mark,
    Thanks for your response. I tell you that I could solve the problem.
    As you said, I Customized the Attachments List Control. I replaced the Action that was called in the Save Button that appeared in the pop-up window for attaching the file.
    The Action that I wrote is the following:

     
    public void buttonSave() throws Exception { 
    getAttachmentsListControlBean_1().button1_action(); 
    
    List<IAttachmentItem> files =  getTemporaryAttachmentsProvider().listAttachments(); 
    int listSize = files.size(); 
    IAttachmentItem lastFile = files.get(listSize-1); 
    int ind = lastFile.getFileName().indexOf(" [1]"); 
    
    if (ind != -1){ 
    String fileName = lastFile.getFileName().substring(0, ind);  
    for (int i = 0; i < listSize-1; i++) { 
    IAttachmentItem f = files.get(i); 
    if (f.getFileName().equals(fileName)){			          getTemporaryAttachmentsProvider().removeAttachment(lastFile.getId()); 
    error(FacesMessage.SEVERITY_WARN, "MESSAGE", null); 
    break; 
    } 
    } 
    } 
    } 

    [/code]

    Regards,

    Marcelo


    #webMethods-BPMS
    #webMethods
    #MWS-CAF-Task-Engine