Monday, March 28, 2011

Estimating Database Table Size

Table->PRODUCT

Sql>analyze table PRODUCTcompute statistics;

Sql> select extent_id, bytes, blocks
from user_extents
where segment_name = 'PRODUCT'
and segment_type = 'TABLE'

"EXTENT_ID" "BYTES" "BLOCKS"
0 1048576 128
1 1048576 128
2 1048576 128


Sql> select blocks, empty_blocks,
avg_space, num_freelist_blocks
from user_tables
where table_name = 'PRODUCT'

"BLOCKS" "EMPTY_BLOCKS" "AVG_SPACE" "NUM_FREELIST_BLOCKS"
376 8 1021 0

Anaylsis
the above shows us:
• we have 128*3(384) blocks allocated to the table
• 8 blocks are totally empty
• 376 block contains data (the other block is used by the system)
• we have an average of about 1k(1021, AVG_SPACE) free on each block used.

Therefore, our table ('FMT027T')

• consumes 376 block
• of which 376block * 8k blocksize - 8 block * 1k free = 3000k is used for our data.


Another Simple SQL is

select sum(bytes) from user_segments where segment_name = 'PRODUCT';

Faces UI field validation

To validate an individual UI field from Faces Side(Mostly for POJO Trees) and dis-allow user to submit the form with Save button, 2 things you need to do
In JSFF, for the UI component, add a Validator Method as below

                <af:inputText value="#{node.Email}" id="i21"
validator="#{TreeSampleBean.ValidatorEmail}"/>



In ManagedBean, add the logic like this

    public void ValidatorEmail(FacesContext facesContext,
UIComponent uIComponent, Object object) {
FacesContext fc = FacesContext.getCurrentInstance();
String email = (String)object;
if (email != null && !email.contains("@")) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "The Email Id must contain @","The Email Id must contain @");
fc.addMessage(uIComponent.getClientId(fc),message);
((RichInputText)uIComponent).setValid(false);
}
}



This wont allow to submit the form unless user rectifies the validation error, because the UIComponent's state is invalid.

Tuesday, March 15, 2011

adf-config.xml caching-rules

<caching-rules xmlns="http://xmlns.oracle.com/adf/faces/rich/acf">
<caching-rule id="cache-js">
<cache>true</cache>
<compress>true</compress>
<duration>99999</duration>
<agent-caching>true</agent-caching>
<cache-key-pattern>*.js</cache-key-pattern>
</caching-rule>
<caching-rule id="cache-png">
<cache>true</cache>
<compress>true</compress>
<duration>99999</duration>
<agent-caching>true</agent-caching>
<cache-key-pattern>*.png</cache-key-pattern>
</caching-rule>
<caching-rule id="cache-css">
<cache>true</cache>
<compress>true</compress>
<duration>99999</duration>
<agent-caching>true</agent-caching>
<cache-key-pattern>*.css</cache-key-pattern>
</caching-rule>
</caching-rules>

Sunday, March 13, 2011

Increasing file upload size using af:inputFile

                <context-param>
<description>Max size of a file that will be uploaded in ram (10MB)</description>
<param-name>oracle.adf.view.faces.UPLOAD_MAX_MEMORY</param-name>
<param-value>10485760</param-value>
</context-param>
<context-param>
<description>Max size of a file that will be uploaded on HDD (100MB)</description>
<param-name>oracle.adf.view.faces.UPLOAD_MAX_DISK_SPACE</param-name>
<param-value>104857600</param-value>
</context-param>
<context-param>
<description>The path of the dir where the files will be uploaded</description>
<param-name>oracle.adf.view.faces.UPLOAD_TEMP_DIR</param-name>
<param-value>/ADFGlassPane/UploadedFiles</param-value>
</context-param>