Posts

Showing posts from 2017

Set navigation drawer selected item from Fragment

  public class HomeFragment extends Fragment {   private NavigationView navigationView ;   public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {  navigationView = (NavigationView)getActivity().findViewById(R.id. navigation_view ); navigationView .setCheckedItem(R.id. nav_staff );   }     use getActivity instead of using view.

Alternative for System.out.println in android

For debugging purposes, alternative solution for System.out.println is to use Log.d d means debug. To see the log simply click on android monitor which is located on the bottom of android studio. select debug (right side of search toolbar) select the emulator of your app running.

com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes)

Android studio error while adding dependencies for RecyclerView. Simple change to the latest version same as your appcompat-v7:25.3.1   for example: compile 'com.android.support:appcompat-v7:25.3.1'   compile 'com.android.support:recyclerview-v7:25.3.1'       Android studio gives warning if the version is not the same.

Missing recyclerview component on android studio

resolve by adding the following dependency on gradle --  module app. add the following to the dependecies    - compile 'com.android.support:recyclerview-v7:+'   sync now on the top of the editor.   credit to: https://stackoverflow.com/questions/24441107/recyclerview-is-missing

Validate Email address in Java

Method to validate email entry in Java. public static boolean isValidEmailAddress(String enteredEmail) {                 boolean isValid = false;         boolean containsDot = false;         boolean containsAt = false;         int dotPosition = 0;         int addPosition = 0;         char addSign = '@';         char dotLetter = '.';                 if (enteredEmail != null && !enteredEmail.isEmpty()){             dotPosition = enteredEmail.lastIndexOf(".");             addPosition = enteredEmail.lastIndexOf("@");                  ...

Primefaces Calendar component

Try to use Primefaces Calendar component realizing unable to use Ajax in command button. solved by updating the form id to form or simple remove the id. leaving only <h:form>

CPU locks at 700Mhz

Device : Laptop Acer Aspire S3 951, core i7 2637M upgraded to windows 10 from windows 7 64x. Cpu clock speed constantly locks at 700Mhz after running the laptop for a while. Able to resolve this in short term, by shut down the laptop, turn off the adaptor, but the lock will come back again after running some heavy task. try run prime95 to test it. updating BIOS somehow work in short term as well. As for long term solution, - updated the chipset driver with the latest provided by Intel ( just overwrite the one comes with Acer for windows 7 driver). - updated the Intel Management Engine with the one provided by Intel. Laptop has been running for few days (without shutting down) heavy processing sometime. Now without having CPU clock speed locks. - updated Not sure if it is related with hard drive failure. PC's hard drive fail soon when try to reformat the PC with windows 10 installer. upgraded to SSD now running smooth.

Task Manager not showing Network utilization

Network utilization was not working in task manager. Problem arised after enable the network discoverable setting in network property. Notice in the device manager the wireless driver automatically adding few other drivers. Problem solved by disabling the network discoverable setting. Both, via network properties setting in windows 10. and also have to manually change via control panel -- network and sharing -- advance sharing setings turn off network discovery.

Reuseable Java Database Connection Class.

Database Connection class. Which is reuseable. Note the select statement return a statement instead of a resultset, as closing the connection will cause the resultset to be closed as well. Without closing the connection, Mysql will throws error  'too many connections made' when user keep pressing refresh button. import java.sql.*; public class DBConn {     String m_Driver = "com.mysql.jdbc.Driver";     Connection connection = null;     Statement statement = null;     ResultSet rset = null;     String dbPassword = "test";     String dbUsername = "root";     String dbName = "testdb";     String connectionURL = "jdbc:mysql://localhost:3306/" + dbName + "?useSSL=false";         public DBConn() {         try {             Class.forName(m_Driver); ...

Mysql Warning -- Establishing SSL connection without server's identity verification is not recommended.

Warning while using lates MySQL J Driver: mysql-connector-java-5.1.41-bin.jar Following is the warning while running the project from eclipse: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. Adding useSSL=false to the Database URL solves the problem. example : "jdbc:mysql://localhost:3306/" + dbName + "? useSSL=false";

JSF 2 with primefaces and omnifaces

Jsf 2 provides extendable for its ui components. Personally, have tried omnifaces and primefaces ui frameworks. Omnifaces provides mostly functionality instead of ui components. For example java.util, user doesn't need to recreate new beans in order to display like time date now from the server. if omnifaces is installed just need to use EL #{now}. On the other hand, Primefaces provides ui support. It comes handy when need to display data. For instead, data table display. It provides lots of way in displaying the data table. Just need to apply the xml namespace. xlms p:http://primefaces.org/ui. installation of omnifaces: - download omnifaces.jar and weld jar - include in the build path if using eclipse, otherwise just drop in web-inf library folder in tomcat - according to the installation guide requires user to add beans.xml in web-inf but i didn't but still able to access via the EL on the webpages. think this applies when need to use the bean.* installation of primefa...

Link css file in jsf

Need to create a folder named "resources" in WebContent folder. Put the css files in css folder in the resources folder created. in the xhtml page add the following: Using <h:head>                <h:outputStylesheet name="css/main.css" />           </h:head>

Eclipse 64 bit Hang at Startup after install JBoss Developer Studio visual studio

Eclipse Neon hang at startup after installed JBoss Developer Studio. Due to JDS using JDK 32 bit for visual editor, however Eclipse environment was set for JDK 64 bit. conflict might happened even using xulrunner. Problem was solved by uninstalling Eclipse and uninstalling the Java JDK 32bit. Remember to Backup your Eclipse WorkSpace (just in case). Uninstalling Eclipse: - Deleting Eclipse installation folder, .Eclipse, eclipse in appdata folder. - Uninstall Java JDK 32 bit from control panel in Windows 10. After uninstalled. - Reinstalling Eclipse Neon with installer. - select your existing workspace. - go to the project that using JBoss visual editor. Project properties --> web editor restore default.

Free AntiVirus and Firewall Experience in 2017

Following are just personal experiences with Windows 10 latest build, happened in year March 2017 Probably the antivirus software have been updated if later. Installation on laptop: - Acer S3 with i7 second generation mobile processor. - RAM 4Gb.  Windows 10 freeze frequently after installing the following Free Antivirus, these are separated installation, have formatted Windows 10 for each installation but still failed : - Free AVG (failed to disable Windows 10 default antivirus, Windows Defender which cause conflict between the  two. have noticed the resources was catch between the two, causing Windows 10 freezes. Avg failed to load UI and etc.) - Free Comodo Internet Suite not sure why keep hangs. CIS managed to stop Windows Defender, but not the default windows 10 firewall. Actually have manually disabled Windows 10 firewall but still failed.  In the end, using Zonealarm free firewall and antivirus. everything is going smooth by then. update: Windows 1...