You need to sign in to do that
Don't have an account?

Clear function not working properly
Hi All,
I want to clear two picklist values & one textfield value on click event of command link.
I have used actionFunction to call controllers method to clear the fields.
But whenever i click clear link on VF page, values vanish for 1-2 sec & again previous values are set in picklists as well as textfield.
I want to implement it through Apex only.
Can anybody tell me possible reason for this??
Thanks
Sachin.
Why havent u used the action property of the command link to call the controller method ? Just use the action and rerender your field section.
Hi swatkat,
Thank you for your reply.
As i want to clear row by passing it's index from VF page, I didn't use action property of the commandlink.
So i need to use actionfunction with param tag passing index to it & using same in controller's method.
Do you have any solution for this??
Thanks,
Sachin.
You can use apex param within the command link tag as well. Like this :
Now in action method, get property from index variable and clear it.
listVariable[Integer.valueOf(index_variable)].PicklistField__c = null;
listVariable[Integer.valueOf(index_variable)].TextField__c = null;
Rerender your section
Hi Bhawani,
Thanks for your solution.
I tried it but it's not working for me.
I am using inner class. Here by I am pasting my clear function & inner class as well.
Clear function :-
public void clear()
{
System.debug('>>>>>>>>>>>>>>>In Clear<<<<<<<<<<<<<<<<<');
Integer indexCount = Integer.valueOf(ApexPages.currentPage().getParameters().get('index'));
//clearmap=new map<string,string>();
System.debug('>>>>>>>>>>>>>>>>Size of list<<<<<<<<<<<<<<<<<'+lstInner.size());
for(innerClass clearobj:lstInner)
{
System.debug('****************In For loop of clear function******************');
System.debug('>>>>>>>>>>>>Value of recCount<<<<<<<<<<<<'+clearobj.recCount);
System.debug('>>>>>>>>>>>>Value of indexCount<<<<<<<<<<<<'+indexCount);
if(indexCount == clearobj.recCount)
{
System.debug('================In if loop of clear function================');
//clearmap.put(clearobj.field,clearobj.value);
//fieldopermap.put(clearobj.field,clearobj.operator);
System.debug('=======Field before clearing======='+clearobj.field);
clearobj.field='--None--';
System.debug('=======Field after clearing======='+clearobj.field);
System.debug('=======Operator before clearing======'+clearobj.operator);
clearobj.operator='';
System.debug('=======Operator after clearing======'+clearobj.operator);
System.debug('=======Value before clearing======='+clearobj.value);
clearobj.value='';
System.debug('=======Value after clearing======='+clearobj.value);
}
}
}
Inner Class :-
public class innerClass
{
/*recCount acts as a index for a row. This will be helpful to identify the row to be deleted */
public Integer recCount{get;set;}
public string field;
public string operator;
public string value;
public list<SelectOption> supportedoperator{get;set;}
public String getfield()
{
return field;
}
public void setfield(String new1)
{
field=new1;
//operaterlist.add(new1);
// system.debug('operaterlist<<<<<<<<<<<<<'+operaterlist);
}
public String getoperator()
{
return operator;
}
public void setoperator(String new2)
{
operator=new2;
// system.debug('selected field list<<<<<<<<<<<<<'+SelectedFieldlist);
}
public String getvalue()
{
return value;
}
public void setvalue(String new3)
{
value=new3;
// Valuelist.add(new3);
}
/*Inner Class Constructor*/
public innerClass(Integer intCount)
{
system.debug('<<<<<<<<<inside inner class construnctor<<<<<<<<<<');
recCount = intCount;
}/*End Inner class Constructor*/
}/*End inner Class*/
VF Page :-
<apex:page controller="GDCDelete" sidebar="false">
<apex:form id="formId">
<apex:actionFunction name="ObjectFileds" action="{!ObjectFields}" reRender="block"/>
<apex:actionFunction name="oper" action="{!op}" rerender="block">
<apex:param name="index" value=""/>
</apex:actionFunction>
<apex:actionFunction name="clear1" action="{!clear}" rerender="formId">
<apex:param name="index" value=""/>
</apex:actionFunction>
<!-- <apex:actionFunction name="oper1" action="{!op1}"> -->
<!-- </apex:actionFunction> -->
<apex:sectionHeader title="Ultra Data Analyzer"/>
<apex:pageBlock id="block">
<b>Select Object:</b>
<apex:selectList multiselect="false" size="1" value="{!SelectedObject}" onChange="ObjectFileds();">
<apex:selectoptions value="{!supportedObject}" />
</apex:selectlist>
<table>
<tr>
<th> </th>
<th>Field</th>
<th>Operator</th>
<th>Value</th>
</tr>
<apex:repeat value="{!lstInner}" var="e1" id="therepeat">
<tr>
<td>
<h3>{!e1.recCount}.</h3>
</td>
<td>
<apex:selectList id="selectionBlock" multiselect="false" style="width:150px;" size="1" value="{!e1.field}" onChange="oper('{!e1.recCount}');" disabled="{!isDisabled}">
<apex:selectoptions value="{!supportedFields}" />
</apex:selectlist>
</td>
<td>
<apex:selectList size="1" style="width:150px;" value="{!e1.operator}" disabled="{!isDisabled}">
<apex:selectOptions value="{!e1.supportedoperator}" />
</apex:selectList>
</td>
<td>
<apex:inputText value="{!e1.value}" disabled="{!isDisabled}"/>
</td>
<td>
<apex:commandbutton value="delete" action="{!delete1}" rerender="block" disabled="{!isDisabled}">
<apex:param name="rowToBeDeleted" value="{!e1.recCount}" assignTo="{!selectedRowIndex}" ></apex:param>
</apex:commandButton>
</td>
<td>
<apex:commandlink value="Clear" onclick="clear1('{!e1.recCount}');" reRender="block" />
</td>
</tr>
</apex:repeat>
</table>
</apex:pageblock>
</apex:form>
</apex:page>
Please help to solve this issue.
Hi Bhawani,
Here is my debug log.
Thanks,
Sachin
You doesnt seem to be have used to assignTo with params in ur code