private String encodeClick ( FacesContext context , Button button ) { String js ; String userClick = button . getOnclick ( ) ; if ( userClick != null ) { js = userClick ; } // +COLON; } else { js = "" ; } String fragment = button . getFragment ( ) ; String outcome = button . getOutcome ( ) ; if ( null != outcome && outcome . contains ( "#" ) ) { if ( null != fragment && fragment . length ( ) > 0 ) { throw new FacesException ( "Please define the URL fragment either in the fragment attribute or in the outcome attribute, but not both" ) ; } int pos = outcome . indexOf ( "#" ) ; fragment = outcome . substring ( pos ) ; outcome = outcome . substring ( 0 , pos ) ; } if ( outcome == null || outcome . equals ( "" ) ) { if ( null != fragment && fragment . length ( ) > 0 ) { if ( ! fragment . startsWith ( "#" ) ) { fragment = "#" + fragment ; } js += "window.open('" + fragment + "', '" ; if ( button . getTarget ( ) != null ) js += button . getTarget ( ) ; else js += "_self" ; js += "');" ; return js ; } } if ( outcome == null || outcome . equals ( "" ) || outcome . equals ( "@none" ) ) return js ; if ( canOutcomeBeRendered ( button , fragment , outcome ) ) { String url = determineTargetURL ( context , button , outcome ) ; if ( url != null ) { if ( url . startsWith ( "alert(" ) ) { js = url ; } else { if ( fragment != null ) { if ( fragment . startsWith ( "#" ) ) { url += fragment ; } else { url += "#" + fragment ; } } js += "window.open('" + url + "', '" ; if ( button . getTarget ( ) != null ) js += button . getTarget ( ) ; else js += "_self" ; js += "');" ; } } } return js ; }
Renders the Javascript code dealing with the click event . If the developer provides their own onclick handler is precedes the generated Javascript code .