Posted by stratosg in Thoughts, Tutorials
on Jul 22nd, 2010 | 0 comments
There has been a fuss on websites that don’t go through validation simply because they have a wrong way of opening a link on a new window. The old conventional way of opening a link on a new window was simply by adding an attribute like:
-
<a href="http://example.com" target="_blank">My new window link</a>
This was both easy to remember and implement. Since the 4.0 strict specification though this is not considered valid any more. I was against that until I read the reason why this changed. Simply because the meta information an HTML document contains is related to the current window and current site. Should you want to refer to a new window it’s simply not within the scope of this page’s description. That’s why it is considered to fall within the client side to implement through Javascript for example.
I am not sure I agree with that since it doesn’t really interfere with the meaning of the meta description of the page that the current HTML does, it’s simply an easy way to do it. On the other hand, since you want the validation to be successful, the easiest way to do it is by adding a small Javascript on the link. You can do it like:
-
<a onclick="window.open(this.href); return false;" href="http://example.com">My new window link</a>
It’s not as hard but it’s definitely not as simply as the first way. What do you prefer? Simplicity or validity? It’s really up to you but I usually go with the first…
Posted by stratosg in Sharepoint, Tutorials
on Jan 5th, 2010 | 0 comments
To cut to the chase, the process of creating a new subsite using WSS is as follows:
- Connect to the main site using SPSite.
- Add the new site using the Add() method on AllWebs collection.
- Do all kinds of magic using the newly created site.
Here is a small C# code example:
-
SPSite rootSite = new SPSite("http://testsite");
-
SPWeb site = rootSite.AllWebs.Add("testsub");
In order to access this site you need to visit “http://testsite/testsub”. Hope this helps!
Posted by stratosg in C#, Sharepoint, Tutorials
on Dec 22nd, 2009 | 2 comments
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:
- A machine running Windows server 2003/08 with Sharepoint installed.
- Microsoft Visual Studio 2005.
- 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:
-
using System;
-
using System.Collections.Generic;
-
using System.Text;
-
using Microsoft.SharePoint;
-
-
namespace TestApp
-
{
-
class Program
-
{
-
static void Main(string[] args)
-
{
-
SPSite root = new SPSite("http://testsite");//this is the URL to the sharepoint site we want to connect to
-
foreach (SPWeb site in root.AllWebs)//looping through the collection of the sites
-
{
-
Console.WriteLine(site.Name);
-
}
-
Console.ReadLine();
-
}
-
}
-
}
From here on, sky is the limit! You can view a documentation of the WSS API here.
Posted by stratosg in Tutorials
on Dec 21st, 2009 | 0 comments
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:
-
import oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding;
-
import javax.faces.application.FacesMessage;
-
import javax.faces.context.FacesContext;
-
import javax.faces.el.ValueBinding;
-
import oracle.adf.model.binding.DCBindingContainer;
-
import oracle.binding.BindingContainer;
-
import oracle.jbo.Transaction;
-
import oracle.jbo.domain.Number;
-
import oracle.jbo.server.ApplicationModuleImpl;
-
import oracle.jbo.uicli.binding.JUIteratorBinding;
-
-
public class ADFUtils {
-
-
private BindingContainer bindings; //this is mainly used to store bindings, but in fact its just an implementation of java.util.Map
-
private DCBindingContainer dcBindings; //whilst this class gives much more control over the bindings
-
private FacesContext ctx;
-
private static Utils instance;
-
private Transaction transaction;
-
-
public ADFUtils(BindingContainer bindings) {
-
this.bindings = bindings;
-
this.ctx = FacesContext.getCurrentInstance();
-
ValueBinding vb = this.ctx.getApplication().createValueBinding("#{bindings}");
-
this.dcBindings = (DCBindingContainer) vb.getValue(this.ctx);
-
this.transaction = dcBindings.getDataControl().getApplicationModule().getTransaction();
-
}
-
-
-
Object obj =
this.
bindings.
get(expression
);
-
return obj;
-
}
-
-
public JUIteratorBinding resolveIterator
(String iterName
) {
-
JUIteratorBinding iter = (JUIteratorBinding)this.getBindings().get(iterName);
-
return iter;
-
}
-
-
public FacesCtrlActionBinding resolveAction
(String actionName
) {
-
FacesCtrlActionBinding action = (FacesCtrlActionBinding) this.getBindings().get(actionName);
-
return action;
-
}
-
-
public void resolveActionAndExecute
(String actionName
) {
-
FacesCtrlActionBinding action = resolveAction(actionName);
-
action.execute();
-
}
-
-
public JUIteratorBinding executeActionAndGetIterator
(String actionName
) {
-
FacesCtrlActionBinding action = resolveAction(actionName);
-
action.execute();
-
JUIteratorBinding iter = action.getIteratorBinding();
-
return iter;
-
}
-
-
/*
-
* This affects only the application module the bindings object belongs to.
-
*/
-
public void globalCommit
() throws Exception {
-
if (transaction.isDirty()) {
-
transaction.commit();
-
System.
out.
println("Changes have been committed");
-
}
-
else {
-
System.
err.
println("No unmodified data to commit");
-
}
-
}
-
-
/*
-
* This affects only the application module the bindings object belongs to.
-
*/
-
public void globalRollback() {
-
if (transaction.isDirty()) { //and transaction has modified data
-
transaction.rollback();
-
System.
out.
println("Changes have been rollbacked");
-
}
-
else {
-
System.
err.
println("No unmodified data to rollback");
-
}
-
}
-
-
//MESSAGES
-
-
public boolean hasErrors() {
-
FacesMessage.Severity maxSeverity = this.ctx.getMaximumSeverity();
-
return (maxSeverity != null? maxSeverity.compareTo(FacesMessage.SEVERITY_ERROR) == 0 || maxSeverity.compareTo(FacesMessage.SEVERITY_FATAL) == 0 : false);
-
}
-
-
public void inform
(String messageText
) {
-
FacesMessage message = new FacesMessage(messageText);
-
message.setSeverity(FacesMessage.SEVERITY_INFO);
-
this.ctx.addMessage(null, message);
-
}
-
-
public void setBindings(BindingContainer bindings) {
-
this.bindings = bindings;
-
}
-
-
public BindingContainer getBindings() {
-
return bindings;
-
}
-
-
public Transaction getTransaction() {
-
return transaction;
-
}
-
-
public DCBindingContainer getDcBindings() {
-
return dcBindings;
-
}
-
-
public ApplicationModuleImpl getAppModuleImpl
(String dataControlName
){
-
javax.faces.context.FacesContext ctx = javax.faces.context.FacesContext.getCurrentInstance();
-
javax.faces.el.ValueBinding bind = ctx.getApplication().createValueBinding("#{data}");
-
oracle.adf.model.BindingContext bindingContext = (oracle.adf.model.BindingContext) bind.getValue(ctx); //resolve binding context
-
oracle.adf.model.binding.DCDataControl dataControl = bindingContext.findDataControl(dataControlName);//find data control by name (defined in DataBindings.cpx) from BindingContext
-
/*
-
* finally get the View Object instance which the iterator is bound to (see the attribute Binds in the iterator definition in the pageDef)
-
* then invoke the magic method executeEmptyRowSet on it
-
*/
-
return (ApplicationModuleImpl) dataControl.getDataProvider();
-
}
-
-
}
So now all you have to do is instantiate the ADFUtil class and invoke its methods!
Posted by stratosg in My Coding, Tutorials
on Aug 4th, 2009 | 17 comments
There has been a lot of hype lately concerning WordPress security and vulnerabilities that are out in the open. This is an open source project so the big advantage is that (and i will quote):
Luckily, the entire WordPress community has our backs. Several folks in the community dug deeper and discovered areas that were overlooked. With their help, the remaining issues are fixed in 2.8.3
This is the heart of any open source project. Since the code is out there in the open, many can take a look and, therefore, discover any potential issues.
Now, i know that many users think that, whenever a new version comes out, they should let other people do the upgrade, check it out and then, they will go on with it. This might be the case with major versions (for instance 2.7.1 -> 2.8.3 as we speak) but it is definitely not the case when we have security patches and fixes (for instance 2.8.1 -> 2.8.2). In these situations, if you don’t upgrade, it means that your WordPress installation is compromised to an outside attack and you shouldn’t be surprised if that happens.
But, does being updated to the latest version, mean that you are absolutely exploit-free? Unfortunately, not. You can never be sure. Not with open source, not with closed source. Never. You never know what someone can come up with to bring down your service. Being updated minimizes that to the absolute minimum, but there is still a chance that it may happen.
Focusing back on WordPress, a very popular exploit is that of the hacker adding his own chunk of code to the core of your installation, hiding it fine. The privilege of that is that they can insert anything they want, for instance, an affiliate link of theirs or a link to a site that contains malicious software, thus their code will be downloaded and executed by every visitor of yours. This is not the only thing an attacker can do, of course, but it is a large portion of the consequences (see this example).
(more…)