+ Start a Discussion

Get Lookup Id in Page Reference

Hi All,
I have two search criteria, one is for Account lookup it has to search in custom object based on the lookup selected value and other one is a text box which needs to enter the name. The user needs to search either using lookup value or text box value.I have one issue when i select the value form lookup and click the button it shows the values but the lookup field remains empty.I need to display the value after search in the lookup field.then only i will perform the validation part just like that.if(ship_partyNo=='' && AccountId=='' ){ run=false;ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR, 'Please enter the value Name or PartyNo'));. }.guide me.

Public class sample_search
public List<sample_unit>Unt_sale{get;set;}
public string partyNo{get;set;}
public Boolean run{get;set;}
public Id AccountId;
public Account cont {get;set;}
public sample_search()
Unt_sale=new List<sample_unit>();
public PageReference runQuery()
try {
    cont=[select id, Name,ParentId  from Account where id=:cont.ParentId limit 1];  
catch(QueryException qe){
   // ApexPages.addMessage(ApexPages.Message(ApexPages.Severity.ERROR, qe.getMessage()));  
string queryunit='select id,name,subject__c,detail__c,Account__r.Id  from Units__c where name=:partyNo OR Account__r.ID =:AccountId';
private void process_unit(List<Units__c> unitsale)
for(Units__c cu:unitsale)
Unt_sale.add(new sample_unit(cu));
//wrapper class for sample_unit
public with sharing class sample_unit
public Units__c unit{get;set;}
public sample_unit(Units__c unt)

<apex:page controller="sample_search" >
<apex:inputField value="{!cont.ParentId}">
<apex:inputText value="{!partyNo}"  id="accinfo1" />
<apex:commandButton value="Go" action="{!runQuery}">
<apex:pageBlock rendered="{!run}">
   <apex:repeat value="{!Unt_sale}" var="us">
   <apex:outputField value="{!us.unit.Name}"/>
   <apex:outputField value="{!us.unit.subject__c}"/>
   <apex:outputField value="{!us.unit.detail__c}"/>