Thursday, December 22, 2011

OAF - Making mandatory Attachement Mandatory

Case - Need to make the Attachment Bean mandatory. Use the below line of code in PFR.

OAMessageAttachmentLinkBean oamessageattachmentlinkbean = (OAMessageAttachmentLinkBean)oawebbean.findChildRecursive("");

String attachVal = (String)oamessageattachmentlinkbean.getAttributeValue(oapagecontext.getRenderingContext(),TEXT_ATTR);

if("None".equals(attachVal))
{
throw new OAException(“Attachment mandatory”,OAException.ERROR);
}

1 comment:

  1. Hi Gyan, This post was really helpful for one of my requirements on making attachments mandatory. I was able to check whether an attachment exists or not successfully. But do you know how I can make sure the attachment is retained if the user navigates to a different page and comes back to the same page: like the following -->
    1) the whole process involves 3-4 steps before submitting the page (3-4 pages)
    2) 1st is entering the transaction. here is where I check for mandatory attachments. and done successfully.
    3) User navigates to the second page for review.
    4) User comes back to first page. Now user deletes the attachment.
    5) Now the above code doesn't validate the mandatory requirement. and allows the user to proceed.

    Do you know how i can overcome this ?

    Thanks
    HKK

    ReplyDelete