Based on your comment below....
Values are passed by reference so you could do the following:
You do not have to use the same controller but in this example I did.
I essentially passed the value I want to set to the component and then has the command link assign the selected value to the attribute that was pointing to the value property passed from the main vf page.
The component then re renders the block on the main page to show that the value was set
Class
public class myExampleClass{
public Id empId{get; set;}
public Id selectedId {get;set;}
public myExampleClass(){}
public myExampleClass(ApexPages.StandardController con){}
public void clickOnName()
{
}
}
Component
<apex:component controller="myExampleClass">
<apex:attribute name="con" type="Contact[]" required="true" description="the contacts"/>
<apex:attribute name="val" type="Id" required="true" description="value to set"/>
<apex:form>
<apex:repeat value="{!con}" var="e" id="r">
<apex:commandLink value="{!e.Name}" reRender="myBlock">
<apex:param name="eId" value="{!e.Id}" assignTo="{!val}"/>
</apex:commandLink>
</apex:repeat>
</apex:form>
</apex:component>
Page
<apex:page standardController="Account" extensions="myExampleClass">
<c:MyTestComponent con="{!Account.Contacts}" val="{!selectedId}"/>
<apex:outPutPanel layout="block" id="myBlock">
{!selectedId}
</apex:outPutPanel>
</apex:page>
Another way would be to pass the controller to the component as indicated here: How do I pass a parameter from component to a Visualforce page?
We may need a bit more information from your code since both in VF page standalone and as a component as the below works just fine using your code...There may be some things that you have not defined but without the full example it is hard to say.
Use the below as a guid and work from there adding stuff you need and see what breaks it
Standalone VF Page
Class
public class myExampleClass{
public Id empId{get; set;}
public myExampleClass(ApexPages.StandardController con){}
public PageReference clickOnName()
{
PageReference newPage = Page.DisplayId;
newPage.getParameters().put('empId', empId);
return newPage.setRedirect(true);
}
}
First VF Page
<apex:page standardController="Account" extensions="myExampleClass">
<apex:form>
<apex:repeat value="{!Account.Contacts}" var="e" id="r">
<apex:commandLink value="{!e.Name}" action="{!clickOnName}">
<apex:param name="eId" value="{!e.Id}" assignTo="{!empId}"/>
</apex:commandLink>
</apex:repeat>
</apex:form>
</apex:page>
Second VF Page
<apex:page >
{!$CurrentPage.parameters.empId}
</apex:page>
Using a component (and second VF page above) as follows:
Component
<apex:component controller="myExampleClass">
<apex:attribute name="con" type="Contact[]" required="true" description="the contacts"/>
<apex:form>
<apex:repeat value="{!con}" var="e" id="r">
<apex:commandLink value="{!e.Name}" action="{!clickOnName}">
<apex:param name="eId" value="{!e.Id}" assignTo="{!empId}"/>
</apex:commandLink>
</apex:repeat>
</apex:form>
</apex:component>
Controller
public class myExampleClass{
public Id empId{get; set;}
public myExampleClass(){}
public PageReference clickOnName()
{
PageReference newPage = Page.DisplayId;
newPage.getParameters().put('empId', empId);
return newPage.setRedirect(true);
}
}
Page using Component
<apex:page standardController="Account">
<c:MyTestComponent con="{!Account.Contacts}"/>
</apex:page>
the above examples essentially uses your code without modification so it proves that it works as expected...