Friday, December 13, 2013

Multi-Lingual JSF

The default answer to having a multilingual page when developing an application is to develop two pages. This will usually add the complexity of managing the pages by resulting in the added effort of maintaining both pages/forms when having adding/amending a function. A simple solution to the problem is by considering the language to be as a separate function and manage it accordingly.

In-line with the function of multi-lingual, let us use the terminology of Function-Oriented application (as a sub-level of OO) where the function of presentation is isolated from the function of language and, as such, is isolated from the core function of the application. Within JSF, you can easily isolate the functionality of a multi lingual application. Let us start by a bundle two bundle files (This can be in a database if you prefer). Here I will use Arabic and English





Then Create a Managed Bean with the scope set as Session Scoped (This is to ensure you maintain the selected language)

public class UserSession implements Serializable{
      private String lang;   
     FacesContext ctx;     
     public void setAr(){   
        try {  
            ExternalContext ctx = FacesContext.getCurrentInstance().getExternalContext();  
        } catch (IOException ex) {  
            Logger.getLogger(UserSession.class.getName()).log(Level.SEVERE, null, ex);  
    public void setEn(){  
        try {  
            ExternalContext ctx = FacesContext.getCurrentInstance().getExternalContext();  
        } catch (IOException ex) {  
            Logger.getLogger(UserSession.class.getName()).log(Level.SEVERE, null, ex);  
    public String getLabel(String label){  
            return ResourceBundle.getBundle("/Bundle"+lang).getString(label);  
        } catch (Exception e){  
            return "No Label for " + label;  
    public String getLang() {  
        return lang;  
    public void setLang(String lang) {  
        this.lang = lang;  

Finally, your JSF page. Depending on the label you need to retrieve, you may use the expression language in the following form:
<h:form dir="#{userSession.getLabel('dir')}">  
    <p:commandLink value="English" action="#{userSession.setEn()}" />  
    <p:commandLink value="عربي" action="#{userSession.setAr()}"  />  
    <h:outputText value="#{userSession.getLabel('next')}"/>  
    <h:outputText value="#{userSession.getLabel('Previous')}"/>  

where dir while define the orientation of the page (left to right or right to left), next and previous will refer to the label title next and Previous respectively in the bundle bundle file based on the selected language. By implementing you code in the above manner, you open the opportunity to configure new languages as you feel free and it will require minimum maintenance from a technical perspective.

Friday, May 3, 2013

Education of Trust in Saudi

Before acknowledging or denying the story, let me tell it to the end.  This is a story of how trust is educated in Saudi.  And although it may sound extreme, I myself would not have believed it if it was not for experiencing it first-hand.  Although the tale might be old, this is the case till today, and it pains me to realize that a country that claims to rule by the Islamic doctrine had failed to create a culture based on common trust between the individuals of its own public and, worse still, between the common public and the governmental.

Our story begins with the academic year of 95/96.  By "chance" our Religious Studies teacher was a fundamental Saudi traditionalist during that year, the same year in which around 75% of students in our school where failed in Religious Studies of which I escaped and my brother fell victim to.  Naturally Students and parents all complained due to the injustice that befell the students.  However, the school's headmaster refused to take a stance.  When we started to request our papers, all requests were rejected and at the start of the new academic year our papers were burnt for all to see in the school's playground.  This situation re-occurred the following year (my final year in intermediate school) in which (thankfully) both my brother and myself escaped failure.  Sadly the Ministry of Education and the school never issued any investigation into the issue.

Think of the implication the above story would have on a student as he is coming of age.  How can he grow to trust anyone?  Better yet, whether it is by chance or not, this happens to many in Saudi (maybe not to the extreme of burning the papers) especially those finalizing their education in institutes of higher education.  Students are failed due to a grudge by the educator, and the educator is rewarded while the student in question is penalized when attempting to expose the corrupt educator.  As such, students graduating into Saudi's growing job market (and new adults into the Saudi Community) are taught not in the best methods of being devious.  They are raised to lie and cheat.  Further yet, they are lectured on truth and honesty and trained on deceit and dishonesty.  Let me take this one step further.  If such tales happen in governmental educational facilities in Saudi, how do we expect to have a generation that truly trust the government official publication or, potentially, any governmental reports and claims?

So how do we fix the issue?  It all starts with the up-bringing.  Students need to be treated with trust (i.e. trust should be practiced not spoken about).  Once we have a good platform to start from, we start punishing the deceitful (regardless of rank).  So a teacher intentionally failing his students, should be punished accordingly.   This will give raise to a culture that believes and understands that lying and cheating is frowned upon by a system that is trying to build trust between its players.

It is not all lost on Saudi culture.  There is still hope to create a community based on trust and loyalty.  A culture that functions correctly and, in accordance, functions on the basis of Islamic values.  But we do need to action this now.  It is time to acknowledge that we. as a Saudi Muslim public, are flawed, that our social values need visiting and that we can potentially progress.  We need to step out of this persona that we have our unique situation (different from any other community) and are perfect in every way.  Once we step away from such arrogance and into a more modest lifestyle and by realistic with ourselves, we will have a chance to truly prevail.

Tuesday, May 1, 2012

My Saudi Identity

During the past several years, Saudi Rights Activists have been propagating the idea of a Saudi Identity shared amongst the people of Saudi Arabia.  Such an identity has been sponsored by King Abdullah since he has consumed kinghood.  This was displayed in the national dialogue and has also been re-emphasized in both the Janadriya festival and the Saudi National Day.   These events have celebrated the diversity of the Saudi Kingdom, which gives us a notion that a Saudi Identity emphasizes on the diversity of Saudi culture, tradition and even faith.  But if that is the case, why is diversity attacked in the kingdom? And why is it that the system does not prosecute against prejudices of all its forms?

When the king sponsored and organized a national dialogue, he tried to emphasize on the aspect of the diversity of the religious faiths within the kingdom.  Yet when it comes to practice, it seems that such a diversity has yet to be recognized.  When a new law is to be studied and implemented, it is considered only within the scope of the Wahhabi School.  Also, the Supreme Court in Saudi Arabia only rules according to interpretation of the Wahhabi school.  In addition, religious education in the kingdom does not tolerate any other faith but the Wahhabi interpretation of Islam.  All other faiths have been deemed as insignificant and, according to some, heretic.  With this in mind, how can my Saudi Identity represent the diversity in Islamic faiths in accordance with the national dialogue?

Another national celebration in Saudi Arabia is the Janadriya festival, a festival that celebrates the cultural diversity of Saudi Arabia and is organized annually by the government.  When visiting the Janadriya festival, the diverse cultures within Saudi Arabia is quite astonishing.  Not only that, but each culture has its own set of convictions, traditions and even local folklore.  Yet, these traditions in Saudi Arabia are only remembered for the ten days of the festival.  As soon as it is over, their history is forgotten and their traditions are ridiculed.  In fact, if it is not a tradition of the Royal Family, it will be considered as valueless and alien.  Therefore, when I start to consider my Saudi Identity within this context, I fail to realize how it can represent my cultural values.

Another potential element of a Saudi identity is the notion of unity which is celebrated during the Saudi National Day, which is held on the 23rd of September.  A “celebration” that has been sponsored by the King used to enforce a sensation of an identity that is unique to the Saudi people.   However, I still cannot identify what I am celebrating.  It cannot be the unity of the Kingdom as my government has not shown a sign of respect towards the different communities that are bound by the borders of this nation.  In fact, it has not tackled those that are seeking to separate the community.  Other than the Saudi National Day, to me, it seems that there is no real attempt to encourage the development of a sense of unity in Saudi Arabia.

With the failure to identify faith, culture and unity as symbols of my Saudi identity, I thought I would seek a sense of equality in how I am viewed by the representatives of the law.  This means that I should be treated as an equal in the land of Saudi Arabia (according to the law).  This also means that the ruling system should also automatically prosecute those that discriminate against me due to tribe, region or faith.  If my Saudi Identity represents my geographical belonging and, in turn, a legal representation of my identity, it means that this system should protect my right as a partial owner of this Saudi land.  Sadly, while considering this particular notion, I feel as if I am journeying through a wonderful pipe dream waiting to wake up.   When considering this aspect of my Saudi identity, whether it is a lack of laws or un-implemented laws, it does not seem that the law is protecting me as a Saudi individual living within the Saudi borders.

What does my Saudi identity mean to me? It has not respected my choice of faith because I am not a Wahhabi (the official faith of the Kingdom).  It has not respected my culture as it has slandered it in any possible way it can.  It has disrespected my right to think freely and has attempted to set an example to me by imprisoning free thinkers from my community and other communities.  It has tried to convince me of the luxurious life a Saudi lives and attempted to hide away the poverty of most Saudis.  It has disrespected my intelligence by propagating its version of Islamic faith as the only true faith and attacking all other faiths including mine.

After discussing the issue of my Saudi identity with colleagues and friends, they usually fail to give me an answer to what this identity means to them.  Given their backgrounds, their identity is usually defined by their family, tribe or city/region.  It is never defined by a united nation that maintains their rights.  It is not the religious values that govern them and it is not a common set of traditional values that are, assumingly, shared between the communities.  One even dared to describe it as a “shameful origin”.  Through my discussions, I did hope to arrive at a justifiable reason to why I should fight for this identity and therefore be proud of.  Sadly, the only conclusion I arrived at is that a Saudi identity, to me, represents the disrespected diversity exemplified by living a lie.

Thursday, March 15, 2012

Firing the First Rocket

“That night, I had some friends over.  While we were chatting, we had the TV on and our show was disturbed for a breaking news bulletin.  The reporter was indicating that a rocket just shot out of northern Saudi and is heading towards Iran.  All of us were quite and all we could think of was that it has finally happened.  The rockets were built in Israel, and it seems that the Saudi regime decided that Iran was a bigger threat to its stability and survival than Israel.  At the point of firing the rockets, the Islamic world was no longer split between Shia and Sunni, but pro-Saudi and anti-Saudi.

The Rocket was not a surprise to many Shia.  For over a year now, there was a continuous attack against their sect in the Saudi owned public media and in governmentally managed mosques without no retaliation nor any clear position from the government.  It was all triggered with one official statement published by the Saudi Ministry of Interior (MoI) targeting its local Shia community in doubting their loyalties.  In the same statement the MoI referred to a Foreign power (at the time thought to be Iran) seeking to tackle the stability in Saudi Arabia.”

What a future to envision.  When imagining the above, some may think to themselves: This seems like a ridiculous thought.  But the question here is how far away from the truth is the above story?  The Loyalty of Saudi Shia has already been questioned by the government and its affiliates.  The official statement of the government had already labeled its Shia public as traitors to their flag and to their land.  You will hear the way the governmentally appointed clerics speak about the Shia during their prayers, labeling them as Rafidhies (deniers of the truth), praying that “may God unleash his full punishment against them”.  To understand this mentality further and what is being propagated, all you have to do is browse through the social media (e.g. facebook and twitter) and you will witness the heavy attack against the Shia public in the form of blessing the Saudi army placed in Qatif wishing that it wipes those “Iranian intruders” who have invaded the eastern province of Saudi Arabia.

Certain Saudi royals have already been quoted in a statement to the United States saying “Cut of head of snake” in a reference to Iran.  The official position of the Wahhabi school (the official Islamic sect of the Saudi state) is that the Shiite’s danger is one that is greater than that of the Jews.  As a portrayal of this belief a conference was held on the 16th of February, 2012 entitled “The truth about the Rafidhi Faith and its Danger Against Sunni Societies” in Riyadh detailing the “Shia threat” on the Sunni community.  In fact, and surprisingly due to this conviction, many conservative Saudis will apparently support an Israeli strike against the dominant Shia state of Iran.  During the past week, according to Peter S. Cohan in his article “What would a Saudi-Supported Israeli Attack on Iran mean for you?”, an anonymous arms dealer has already visited Israel and Saudi  to meet officials on both sides to discuss a potential Israeli attack on Iran from within the Saudi borders.  If this is true, can we place the assumption that the Saudi regime, through its relaxed monitoring against the attacks aimed at the Shia population,  is preparing for the whiplash it may get from the Islamic community under such circumstances? I leave that for you to decide.