Tuesday 22 April 2014

Table Horizant Scroll Bar

In order to lessen the pain of the user and to have better UI design, we will render scroll bars both horizontal and vertical just surrounding the table
as , shown in the image below :



So, now lets focus how can we bring these scroll bars. In that case you can use the DIV tag to do the job for you.Put 2 RawText Bean(named DivStart, DivEnd), before and after the Table Bean in the JRAD page as shown in the image below IN JDEVELOPER:



public class ScrollEnable extends OAControllerImpl
{
  public static final String RCS_ID="$Header$";
  public static final boolean RCS_ID_RECORDED =
        VersionInfo.recordClassVersion(RCS_ID, "%packagename%");

public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
//SEE ALL PARAMETER values you need to pass in the java comments of the method
addScrollBarsToTable(pageContext, webBean,"DivStart","DivEnd",false,"1400",true,"400");
}
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
}
public void addScrollBarsToTable(OAPageContext pageContext,
OAWebBean webBean,
String preRawTextBean,
String postRawTextBean,
boolean horizontal_scroll, String width,
boolean vertical_scroll, String height)
{
String l_height = "1400";
String l_width = "400";
pageContext.putMetaTag("toHeight",
"<style type=\"text/css\">.toHeight {height:24px; color:black;}</style>");

OARawTextBean startDIVTagRawBean =
(OARawTextBean) webBean.findChildRecursive(preRawTextBean);
if (startDIVTagRawBean == null)
{
throw new OAException("Not able to retrieve raw text bean just above the table bean. Please verify the id of pre raw text bean.");
}

OARawTextBean endDIVTagRawBean =
(OARawTextBean) webBean.findChildRecursive(postRawTextBean);
if (endDIVTagRawBean == null)
{
throw new OAException("Not able to retrieve raw text bean just below the table bean. Please verify the id of post raw text bean.");
}

if (!((height == null) || ("".equals(height))))
{
try
{
Integer.parseInt(height);
l_height = height;
}
catch (Exception e)
{
throw new OAException("Height should be an integer value.");
}
}


if (!((width == null) || ("".equals(width))))
{
try
{
Integer.parseInt(width);
l_width = width;
}
catch (Exception e)
{
throw new OAException("Width should be an integer value.");
}
}

String divtext = "";
if ((horizontal_scroll) && (vertical_scroll))
{
divtext =
"<DIV style='width:" + l_width + ";height:" + l_height + ";overflow:auto;padding-bottom:20px;border:0'>";
}
else if (horizontal_scroll)
{
divtext =
"<DIV style='width:" + l_width + ";overflow-x:auto;padding-bottom:20px;border:0'>";
}
else if (vertical_scroll)
{
divtext =
"<DIV style='height:" + l_height + ";overflow-y:auto;padding-bottom:20px;border:0'>";
}
else
{
throw new OAException("Both vertical and horizintal scrollbars are passed as false,hence, no scrollbars will be rendered.");
}
startDIVTagRawBean.setText(divtext);
endDIVTagRawBean.setText("</DIV>");
}
}



In addScrollBarsToTable
Parameter1:OAPageContext object.
Paremeter 2:OAWebBean object
Paremter 3:Id of rawtext bean1
Parameter4:Id of rawtext bean2
Parameter 5:True will enable Horizontal Scroll Bar,No Will disable it.
Parameter6:1400 Size of the Table Extent to Apply  scroll bar
Parameter 7:True will enable Vertical Scroll Bar,No Will disable it.
Parameter8: 400 Size of the Table Extent to Apply  scroll bar

Usage of Record Type in Callable Statement

write below code under processFormRequest  based on your conditions.we can process record types using below Process

Import statement:
import oracle.jdbc.driver.OracleCallableStatement;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;
 import java.sql.SQLException;

String str[] = new String[30];

       for(int i = 0; i < 10; i++)

       try

     {

        str[i] = i;
      }
      catch(Exception e)

    {
          str[i] = null;
    }

  try
 {

   ArrayDescriptor segvaldesc = ArrayDescriptor.createDescriptor("SEGMENT_VALUES", connection);

   ARRAY segval = new ARRAY(segvaldesc, connection, str);

  OracleCallableStatement ocs = (OracleCallableStatement)connection.prepareCall("Begin  
   XXHR_SIT_VALIDATION_PKG.VALIDATE_RECORD 
  (p_sit_code=>:1,p_segment=>:2,p_person_id=>:3,p_employee_id=>:4,p_message=>:5); end;");

  ocs.setString(1, s_struc_code);
  ocs.setARRAY(2, segval);
  ocs.setString(3, v_person_id);
  ocs.setString(4, v_emp_id);
  ocs.registerOutParameter(5, 12);
  ocs.execute();

  v_message = ocs.getString(5);
  ocs.close();
 }
catch(SQLException sqlexception)
{
throw new OAException("Error " + sqlexception.getMessage(), (byte)2);
}

Making Attachement Mandatory

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);