You need to sign in to do that
Don't have an account?
Rerender is not working properly.
Public PageReference DoSearch()
{
ListAcc = [Select Id, Name, BillingCity From Account Where Name Like :('%' + SearchWord + '%')];
For(Account acc : ListAcc)
{
ListAcc1.add(new aAccount(acc));
}
System.debug('========== ListAcc ============' + ListAcc);
System.debug('========== ListAcc1 ============' + ListAcc1);
return null;
}
=================================
<apex:page Controller="sclass6Again">
<apex:form >
<apex:pageBlock >
<apex:pageblockSection >
<apex:pageblockSectionItem >
<apex:outputLabel >
Search Text :
</apex:outputLabel>
<apex:panelGroup >
<apex:inputText value="{!SearchWord}"/>
<apex:commandButton value="Go" Action="{!doSearch}">
<apex:actionSupport event="onclick" reRender="x" />
</apex:commandButton>
</apex:panelGroup>
</apex:pageblockSectionItem>
</apex:pageblockSection>
<apex:pageBlockSection title="Results" id="x" >
<apex:pageBlockTable value="{!ListAcc1}" var="v">
<apex:column value="{!v.aRecord.name}"/>
<apex:column >
<apex:inputCheckbox value="{!v.Check}"/>
</apex:column>
<apex:column value="{!v.b}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Public Class sclass6Again
{
Public String SearchWord{get;set;}
List<Account> ListAcc = new List<Account>();
List<aAccount> ListAcc1 = new List<aAccount>();
Public List<Account> getListAcc()
{
return ListAcc;
}
Public List<aAccount> getListAcc1()
{
return ListAcc1;
}
Public PageReference DoSearch()
{
ListAcc1.clear();
ListAcc = [Select Id, Name, BillingCity From Account Where Name Like :('%' + SearchWord + '%')];
For(Account acc : ListAcc)
{
ListAcc1.add(new aAccount(acc));
}
System.debug('========== ListAcc ============' + ListAcc);
System.debug('========== ListAcc1 ============' + ListAcc1);
return null;
}
Public Class aAccount
{
Public Account aRecord{get; set;}
Public String b{get; set;}
Public Boolean Check{get; set;}
Public aAccount(Account acc)
{
aRecord = acc;
Check = False;
if(aRecord.BillingCity == Null)
{
b = 'Not Provided';
}
Else
{
b = aRecord.BillingCity;
}
}
}
}
All Answers
Add that in Button
<apex:page Controller="sclass6Again">
<apex:form >
<apex:pageBlock >
<apex:pageblockSection >
<apex:pageblockSectionItem >
<apex:outputLabel >
Search Text :
</apex:outputLabel>
<apex:panelGroup >
<apex:inputText value="{!SearchWord}"/>
<apex:commandButton value="Go" Action="{!doSearch}" reRender="x">
<apex:actionSupport event="onclick" />
</apex:commandButton>
</apex:panelGroup>
</apex:pageblockSectionItem>
</apex:pageblockSection>
<apex:pageBlockSection title="Results" id="x" >
<apex:pageBlockTable value="{!ListAcc1}" var="v">
<apex:column value="{!v.aRecord.name}"/>
<apex:column >
<apex:inputCheckbox value="{!v.Check}"/>
</apex:column>
<apex:column value="{!v.b}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
it is not working.
displays the list for 1 sec then disappear.
Public Class sclass6Again
{
Public String SearchWord{get;set;}
List<Account> ListAcc = new List<Account>();
List<aAccount> ListAcc1 = new List<aAccount>();
Public List<Account> getListAcc()
{
return ListAcc;
}
Public List<aAccount> getListAcc1()
{
return ListAcc1;
}
Public PageReference DoSearch()
{
ListAcc1.clear();
ListAcc = [Select Id, Name, BillingCity From Account Where Name Like :('%' + SearchWord + '%')];
For(Account acc : ListAcc)
{
ListAcc1.add(new aAccount(acc));
}
System.debug('========== ListAcc ============' + ListAcc);
System.debug('========== ListAcc1 ============' + ListAcc1);
return null;
}
Public Class aAccount
{
Public Account aRecord{get; set;}
Public String b{get; set;}
Public Boolean Check{get; set;}
Public aAccount(Account acc)
{
aRecord = acc;
Check = False;
if(aRecord.BillingCity == Null)
{
b = 'Not Provided';
}
Else
{
b = aRecord.BillingCity;
}
}
}
}
Is there any reason for adding this line?
<apex:actionSupport event="onclick" />
If not please remove that.
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks