The “European Knowledge” experiment

I have just started a very small poll that is part of a small experiment i am conducting. If you’re interested please check it out and vote here. Please do not lookup the answer online. It will only take a minute to complete. The results of the experiment will be revealed once i close the survey, in about a week or so. I would like to thank anyone that participates in advance.

Stop joining spam meaningless Facebook groups

I’ve seen this trend taking off the last year or so. Every spammer out there has included Facebook in their plans. Here is how it works:

  1. I have a stupid site i want to promote or a stupid product or anything that you wouldn’t actually even pay attention to.
  2. I go to Facebook and create a new group. I give it a smart, funny, witty, inviting name such as “I am always right and when i’m not i’m rightfully wrong”. How funny.
  3. I spam invite all my friends to join. They find it funny enough and do join.
  4. The group shows up in their “Info” box.
  5. More users notice it and join. Moreover users that already join suggest to their friends to join as well.
  6. The group shows up slowly in many walls as “Dumbass join the group “I’m always right and when i’m not i’m rightfully wrong”“.
  7. Facebook also starts suggesting it to other users because people in their contact list are member. You must have seen them “”I’m always right and when i’m not i’m rightfully wrong” Dumbass is a fan. Become a fan.
  8. In no time this shitty thing goes viral. Thousands of users actually are members of the group in a matter of days/weeks.

Now one would ask “Why is that spam? It’s fun!”. Ok count with me:

  • The group administrator, a very clever spammer if i might add, has indirect access to our timeline. This means that whatever he posts on the group’s wall, ends up in our timeline. Thus, we are actually subjected to “free ads” if i might use the term.
  • Since Facebook will list this in your Info box and moreover suggest it to your friends (if you haven’t done that already) it will just keep on going viral. Which means even more free advertising.

In most cases those groups promote or will try to promote something at some point or the other. The thing is why should you join? You like a quote? Freakin post it on your wall as a quote. Don’t join the stupid group so i can be bugged as well. You need to consider two things:

  1. Facebook groups were created to group people and their activities. You like a blog? Join their group. You are in a community (for instance your local basketball team)? Join the group. That’s the idea. RTFM!
  2. In Facebook we are a network. That’s the original idea. Which means that if you’re my friend i get all your posts on my timeline. Don’t spam me!

And since i’m in the topic, as a side note, i want to say this. Stop freakin posting your farmville, mafia wars or any other stupid game’s achievements  on your wall. Lord! Do i really need to know that you found a stupid virtual cow in your so called farm?

That’s it. I vented. Thanks for listening and God bless :)

Hook up C# with Windows Sharepoint Services (WSS) tutorial

In this small tutorial i shall demonstrate how to hook up C# to use the Windows Sharepoint Services API (WSS). It’s fairly simple and straightforward. You need the following:

  1. A machine running Windows server 2003/08 with Sharepoint installed.
  2. Microsoft Visual Studio 2005.
  3. About 15 minutes.

For the purposes of this example, we will create a small console application that will list all the sites of a Sharepoint site. First of open Visual Studio and create a new Visual C# console application. Next step is adding the reference to the WSS API on our project. To do so, you can go on the explorer window, right click on the “References” and click “Add Reference…”. On the window that will show up choose “Windows Sharepoint Services” dll from the .NET packages.

Once this step is done, off to the code:

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Microsoft.SharePoint;
  5.  
  6. namespace TestApp
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             SPSite root = new SPSite("http://testsite");//this is the URL to the sharepoint site we want to connect to
  13.             foreach (SPWeb site in root.AllWebs)//looping through the collection of the sites
  14.             {
  15.                 Console.WriteLine(site.Name);
  16.             }
  17.             Console.ReadLine();
  18.         }
  19.     }
  20. }

From here on, sky is the limit! You can view a documentation of the WSS API here.

How to use bindings in the backing beans in ADF 10g

This is a follow up to the original post about acquiring a bindings object in backing beans in ADF. Some have had the question, how to use the bindings for standard operations in the backing beans. Hence this post!

The answer is – easy. As soon as you’ve got the bindings (oracle.binding.BindingContainer object) instance, you can do a lot of interesting stuff with it.

Always keep in mind, that it represents the page definition, meaning that it “contains” whatever the pageDef does.

Create a class like the following one:

  1. import oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding;
  2. import javax.faces.application.FacesMessage;
  3. import javax.faces.context.FacesContext;
  4. import javax.faces.el.ValueBinding;
  5. import oracle.adf.model.binding.DCBindingContainer;
  6. import oracle.binding.BindingContainer;
  7. import oracle.jbo.Transaction;
  8. import oracle.jbo.domain.Number;
  9. import oracle.jbo.server.ApplicationModuleImpl;
  10. import oracle.jbo.uicli.binding.JUIteratorBinding;
  11.  
  12. public class ADFUtils {
  13.  
  14. private BindingContainer bindings; //this is mainly used to store bindings, but in fact its just an implementation of java.util.Map
  15. private DCBindingContainer dcBindings; //whilst this class gives much more control over the bindings
  16. private FacesContext ctx;
  17. private static Utils instance;
  18. private Transaction transaction;
  19.  
  20. public ADFUtils(BindingContainer bindings) {
  21. this.bindings = bindings;
  22. this.ctx = FacesContext.getCurrentInstance();
  23. ValueBinding vb = this.ctx.getApplication().createValueBinding("#{bindings}");
  24. this.dcBindings = (DCBindingContainer) vb.getValue(this.ctx);
  25. this.transaction = dcBindings.getDataControl().getApplicationModule().getTransaction();
  26. }
  27.  
  28. public Object resolveExpresssion(String expression) {
  29. Object obj = this.bindings.get(expression);
  30. return obj;
  31. }
  32.  
  33. public JUIteratorBinding resolveIterator(String iterName) {
  34. JUIteratorBinding iter = (JUIteratorBinding)this.getBindings().get(iterName);
  35. return iter;
  36. }
  37.  
  38. public FacesCtrlActionBinding resolveAction(String actionName) {
  39. FacesCtrlActionBinding action = (FacesCtrlActionBinding) this.getBindings().get(actionName);
  40. return action;
  41. }
  42.  
  43. public void resolveActionAndExecute(String actionName) {
  44. FacesCtrlActionBinding action = resolveAction(actionName);
  45. action.execute();
  46. }
  47.  
  48. public JUIteratorBinding executeActionAndGetIterator(String actionName) {
  49. FacesCtrlActionBinding action = resolveAction(actionName);
  50. action.execute();
  51. JUIteratorBinding iter = action.getIteratorBinding();
  52. return iter;
  53. }
  54.  
  55. /*
  56. * This affects only the application module the bindings object belongs to.
  57. */
  58. public void globalCommit() throws Exception {
  59. if (transaction.isDirty()) {
  60. transaction.commit();
  61. System.out.println("Changes have been committed");
  62. }
  63. else {
  64. System.err.println("No unmodified data to commit");
  65. }
  66. }
  67.  
  68. /*
  69. * This affects only the application module the bindings object belongs to.
  70. */
  71. public void globalRollback() {
  72. if (transaction.isDirty()) { //and transaction has modified data
  73. transaction.rollback();
  74. System.out.println("Changes have been rollbacked");
  75. }
  76. else {
  77. System.err.println("No unmodified data to rollback");
  78. }
  79. }
  80.  
  81. //MESSAGES
  82.  
  83. public boolean hasErrors() {
  84. FacesMessage.Severity maxSeverity = this.ctx.getMaximumSeverity();
  85. return (maxSeverity != null? maxSeverity.compareTo(FacesMessage.SEVERITY_ERROR) == 0 || maxSeverity.compareTo(FacesMessage.SEVERITY_FATAL) == 0 : false);
  86. }
  87.  
  88. public void inform(String messageText) {
  89. FacesMessage message = new FacesMessage(messageText);
  90. message.setSeverity(FacesMessage.SEVERITY_INFO);
  91. this.ctx.addMessage(null, message);
  92. }
  93.  
  94. public void setBindings(BindingContainer bindings) {
  95. this.bindings = bindings;
  96. }
  97.  
  98. public BindingContainer getBindings() {
  99. return bindings;
  100. }
  101.  
  102. public Transaction getTransaction() {
  103. return transaction;
  104. }
  105.  
  106. public DCBindingContainer getDcBindings() {
  107. return dcBindings;
  108. }
  109.  
  110. public ApplicationModuleImpl getAppModuleImpl(String dataControlName){
  111. javax.faces.context.FacesContext ctx = javax.faces.context.FacesContext.getCurrentInstance();
  112. javax.faces.el.ValueBinding bind = ctx.getApplication().createValueBinding("#{data}");
  113. oracle.adf.model.BindingContext bindingContext = (oracle.adf.model.BindingContext) bind.getValue(ctx); //resolve binding context
  114. oracle.adf.model.binding.DCDataControl dataControl = bindingContext.findDataControl(dataControlName);//find data control by name (defined in DataBindings.cpx) from BindingContext
  115. /*
  116. * finally get the View Object instance which the iterator is bound to (see the attribute Binds in the iterator definition in the pageDef)
  117. * then invoke the magic method executeEmptyRowSet on it
  118. */
  119. return (ApplicationModuleImpl) dataControl.getDataProvider();
  120. }
  121.  
  122. }

So now all you have to do is instantiate the ADFUtil class and invoke its methods!