In my code, I have 2 pageblockTable with 2 values(apex). They are displaying data in 2 different tables. First pageblockTable displays the data based on search button after giving input. Second pageBlockTable displays data when the page loads. My requirement is to, When I click search button the second pageblockTable old data(default) should disappear and This search data should display in the second pageblockTable.
How to achieve?
Page:
<apex:pageBlock >
<apex:pageBlockSection >
<apex:outputLabel ><B>Search</B></apex:outputLabel><BR/>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Enter Aadhar card Number" for="AdharcardNumberID"/>
<apex:inputText value="{!adharcard}" id="AdharcardNumberId"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Last name" for="lastnameId"/>
<apex:inputText value="{!lastname}" id="lastnameId"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Surname" for="SurnameId"/>
<apex:inputText value="{!surname}" id="SurnameId"/>
</apex:pageBlockSectionItem>
<apex:commandButton value="Search" action="{!searchRec}" reRender="recMatch, recNotMatch"/>
<apex:outputPanel id="recMatch">
<apex:pageblockSectionItem rendered="{!Match}">
<apex:pageblockTable value="{!searchObj}" var="obj">
<apex:column value="{!obj.field1}"/>
<apex:column value="{!obj.field2}"/>
<apex:column value="{!obj.field3}"/>
<apex:column value="{!obj.field4}"/>
<apex:column value="{!obj.field5}"/>
<apex:column value="{!obj.field6}"/>
<apex:column value="{!obj.field7}"/>
<apex:column value="{!obj.field8}"/>
</apex:pageblockTable>
</apex:pageblockSectionItem>
</apex:outputPanel>
<apex:outputPanel id="recNotMatch">
<apex:pageBlockSectionItem rendered="{!NoMatch}"> Record Not Found!</apex:pageBlockSectionItem>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
<!--second PageblockTable -->
<apex:pageBlock id="tablePB">
<apex:pageBlockSection title="Obj List">
<apex:pageBlockTable value="{!Objects}" var="ob">
<apex:column headerValue="Last Name">
<apex:outputLink value="/{!vict.id}" target="_blank"><apex:outputText value="{!ob.Name}" /></apex:outputLink>
</apex:column>
<apex:column value="{!ob.field1}"/>
<apex:column value="{!ob.field1}"/>
<apex:column value="{!ob.field1}"/>
<apex:column value="{!ob.field1}"/>
<apex:column value="{!ob.field1}"/>
<apex:column value="{!ob.field1}"/>
<apex:column value="{!ob.field1}"/>
<apex:column value="{!ob.field1}"/>
</apex:pageBlockTable><BR/>
list
variable. Initially fetch all the records and when user searches for something, modify the list with searched records.