Saturday, November 18, 2017

Firefox 57 and Tree Style Tabs BROKEN

It's amazing how much damage the new version of Firefox is inflicting to the user community.

If you are a Tree Style Tab user and HATE seeing the tabs being displayed on top and left at same time:

https://www.reddit.com/r/firefox/comments/736cji/how_to_hide_native_tabs_in_firefox_57_tree_style/

In a nutshell (on Windows)

open a cmd prompt
cd %APPDATA%
cd Mozilla/Firefox/Profiles/
cd *** (whatever is named your profile.... no clue why they could not choose a fixed name...)
mkdir chrome

in this chrome folder, create a userChrome.css file with this content:

@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");

/* to hide the native tabs */
#TabsToolbar {
    visibility: collapse;
}

/* to hide the sidebar header */
#sidebar-header {
    visibility: collapse;
}



and restart Firefox.... and pray that with next release they will not break everything again.

For the time being I have disabled the automatic update of Firefox...






Friday, November 17, 2017

JSF crash course

Home page http://www.oracle.com/technetwork/java/javaee/javaserverfaces-139869.html , particularly this introduction https://docs.oracle.com/javaee/5/tutorial/doc/bnaph.html

Decent introduction https://www.youtube.com/watch?v=KwUAA4L_9AA&list=PLEAQNNR8IlB4S8nNUlS0ArfgU1nXlhdRu&index=1 (a bit too verbose, skip the central videos on how to install sw).

The helloworld code is here https://github.com/vernetto/JavaMonAmour/tree/master/pvjsfhello


Primefaces https://www.primefaces.org/

Richfaces http://richfaces.jboss.org/


Great collection of books on JSF http://www.javatechblog.com/java/best-books-to-learn-jsf-for-java-developers/ (mostly very ancient)



Remote debug Wildfly with Eclipse, KeycloakPrincipal

./standalone.bat --debug

This generates


JAVA_OPTS: "-Dprogram.name=standalone.bat -Xms64M -Xmx512M -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"

===============================================================================

Listening for transport dt_socket at address: 8787



In fact, in standalone.bat you find this code:

rem Set debug settings if not already set
if "%DEBUG_MODE%" == "true" (
   echo "%JAVA_OPTS%" | findstr /I "\-agentlib:jdwp" > nul
  if errorlevel == 1 (
     set "JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_socket,address=%DEBUG_PORT_VAR%,server=y,suspend=n"
  ) else (
     echo Debug already enabled in JAVA_OPTS, ignoring --debug argument
  )
)


You can now follow these instructions https://www.eclipse.org/jetty/documentation/9.4.x/debugging-with-eclipse.html to configure Eclipse,
or simply

right-click on project in eclipse, Debug as, Remote Java Application, then you get this dialog


so I can trace this code:



public String getPrincipalName(HttpServletRequest request) {
KeycloakPrincipal keycloakPrincipal = (KeycloakPrincipal)request.getUserPrincipal();
return keycloakPrincipal != null ? keycloakPrincipal.getKeycloakSecurityContext().toString() : "unauthenticated" ;
}


and discover this:



In a ManagedBean you can inject a Principal, and Wildfly will take care of it transparently:

@Named
@RequestScoped
public class EventViewBean {
@Inject Principal principal;

public void getPrincipal() {
System.out.println("principal class name is " + principal.getClass().gtName());
}
}


This will print a:

org.jboss.weld.security.Principal$$Proxy$_$$_Weld$Proxy$


and not - as expected - a http://www.keycloak.org/docs-api/3.2/javadocs/org/keycloak/KeycloakPrincipal.html who however also implements the https://docs.oracle.com/javase/7/docs/api/java/security/Principal.html interface