sabato 25 agosto 2012

JSF EL different behaviour with boolean vs Boolean Bean attribute

According Java Bean specification when you define a bean attribute (any kind of type - primitive or Object) you should also define getter and setter methods.

For get method a special attribute is the boolean attribute; infact for boolean attribute you may implement both  'is' method and 'get' method.

Sometimes you may choose for some reason to change an attribute from boolean to Boolean type.

You can make your change but with some concerns:

-consider how attribute initialization differs between  primitive boolean (compiler force you to initializate to 'false' or 'true' value) and Boolean (you can leave it null).

- another great difference is about getter methods: infact with Boolean type you have to implement get method and not is method (allowed only for boolean) otherwise you may expect errors.



Here a sample:

HTML JSF page

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">
   <h:head>
      <title>Welcome</title>
   </h:head>
   <h:body>
      <h:form>
         <h3>Please enter your name and password.</h3>  
         <table>
            <tr>
               <td>Name:</td>
               <td><h:inputText value="#{user.name}" rendered="#{user.illiquid}" /></td>
            </tr>
            <tr>
               <td>Password:</td>
               <td><h:inputSecret value="#{user.password}"/></td>
            </tr>
         </table>
         <p><h:commandButton value="Login" action="welcome"/></p>
      </h:form>
   </h:body>
</html>

 That's is user backing bean with visible property type changed from boolean to Boolean.

package com.corejsf;

import java.io.Serializable;
import javax.inject.Named;
   // or import javax.faces.bean.ManagedBean;
import javax.enterprise.context.SessionScoped;
   // or import javax.faces.bean.SessionScoped;

@Named("user") // or @ManagedBean(name="user")
@SessionScoped
public class UserBean implements Serializable {
   private String name;
   private String password;
   private Boolean visible = true;

   public String getName() { return name; }  
   public void setName(String newValue) { name = newValue; }

   public String getPassword() { return password; }
   public void setPassword(String newValue) { password = newValue; }  
  
   public Boolean isVisible(){
       return visible;
   }
  }

Here the error
/index.xhtml @15,83 rendered="#{user.visible}": The class 'com.corejsf.UserBean$Proxy$_$$_WeldClientProxy' does not have the property 'visible'.

And here fixed bean

package com.corejsf;

import java.io.Serializable;
import javax.inject.Named;
   // or import javax.faces.bean.ManagedBean;
import javax.enterprise.context.SessionScoped;
   // or import javax.faces.bean.SessionScoped;

@Named("user") // or @ManagedBean(name="user")
@SessionScoped
public class UserBean implements Serializable {
   private String name;
   private String password;
   private Boolean visible = true;

   public String getName() { return name; }  
   public void setName(String newValue) { name = newValue; }

   public String getPassword() { return password; }
   public void setPassword(String newValue) { password = newValue; }  
  
   public Boolean getVisible(){
       return visible;
   }
  
  



giovedì 16 agosto 2012

index rebuild oracle crontab - beta

Still BETA


#!/bin/bash
 
##function
check_id_oracle() {
whoami | grep oracle > /dev/null
if [[ "$?" -eq 0 ]]
then
echo "good - you are oracle"
else
echo "you must be oracle"
exit 1
fi
}
 
 
check_be_active() {
ps -ef | grep "[/j]boss-4.2.3GA" > /dev/null
if [[ "$?" -eq 0 ]]
then
echo "good - be active"
else
echo "be stand by"
exit 1
fi
}
 
. .profile
check_id_oracle
check_be_active
v_schema=INEM_REP
sqlplus -s INEM_REP/INEM_REP@XE <<-EOF 2>&1 > /dev/null
set head off
set linesize 60
spool /tmp/rebuild_idx_${v_schema}.sql
select 'spool /tmp/rebuild_idx_${v_schema}.log' from dual;
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='ITEMCONFIG' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='SINGLE_VALUE_ATTRIBUTE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='STRUCT_VALUE_ATTRIBUTE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='MULTI_VALUE_ATTRIBUTE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='VALUES_MV_ATTRIBUTES' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='VALUES_STRUCT_ATTRIBUTES' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='NGN_ENTITY_NODE_PROPERTY' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='NGN_NODE_INTERFACE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='NGN_NODE_INTERFACE_CREDENTIALS' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='L_AGGR_TO_NGN_NODE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='L_AGGR_DOMAINS' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='L_AGGR_INTERFACE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='L_AGGR_INTERFACE_CREDENTIALS' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='L_AGGR_INTER_CRED_ATTRIBUTE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='L_AGGR_MV_PROPERTY' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='L_AGGR_VALUES_MV_PROPERTY' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='LOGICAL_AGGREGATION' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='NGN_ENTITY_NODE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='WOS_LOGICAL_AGGREGATION' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='WOS_REQUIRED_ATTRIBUTE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='WOS_LOGICAL_CONFIGURATION' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='WOS_ATTR' and INDEX_TYPE='NORMAL';
 
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='WOS_OTHER_NODE_IP_TYPE' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='WOS_REQUIRED_PROPERTY' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='WOS_PROTOCOLS' and INDEX_TYPE='NORMAL';
select 'alter index ' ||INDEX_NAME||' rebuild online;' from user_indexes where TABLE_NAME='WOS_CREDENTIAL_ATTRIBUTES' and INDEX_TYPE='NORMAL';
spool off
@/tmp/rebuild_idx_${v_schema}.sql
exit;
EOF
echo "done"
echo "logs index under /tmp/rebuild_idx_INEM_REP.log"

Working with working set in eclipse

Working with working set in eclipse:

Let assume an application made of many related  eclipse (for example a gui project many depends on many projects of back end layer). To have a working compilation no choice, you have to import all projects in eclipse. But it is noising have so many projects you don’t work to on project explorer only for compilation needs (see example). To avoid that problem you may use eclipse working set which allows you to have a restricted view of only projects of your interest (other projects still live behind)

See example by pictures:
Step1 = 2 projects in my workspace -> select working set menu




Step2= create a new working set

Step3 = select projects belonging to working set



Step4 = from fist menu (see figure for step 1) select working set you want work to