4

I don't know what is wrong with the code, I read a lot about the commandbutton and param, but it doesn't work.

The Debug shows me that the value of the MS_Item is Null. 07:44:00.0 (8771917)|USER_DEBUG|[8]|DEBUG|my MS_Item: null

PAGE:

<apex:page controller="clicktest">

    <apex:form>

    <apex:commandButton action="{!Stats_In}" value="click" reRender="">
        <apex:param name="MS_Item" value="MS_Item_45382" assignTo="{!MS_Item}" />
    </apex:commandButton>

    </apex:form>    

</apex:page>

CLASS:

public class clicktest {

    Public String MS_Item {get; set;}

    public PageReference Stats_In() {
        MedienServer_Stats__c sta = new MedienServer_Stats__c();
        sta.MS_Item__c = MS_Item;    
        System.debug('my MS_Item: ' +MS_Item);
        INSERT sta;
        RETURN NULL;
    }

}

2 Answers 2

5

Need to be add a DummyID for reRedner.

<apex:page controller="clicktest">
    <apex:form>
    <apex:commandButton action="{!Stats_In}" value="click" reRender="dummyId">
        <apex:param name="MS_Item" value="MS_Item_45382" assignTo="{!MS_Item}" />
    </apex:commandButton>
    </apex:form>    
</apex:page>
2

Just add a dummy panel and reRender it. It will work.

<apex:outputPanel id="panel2">

</apex:outputPanel>

<apex:commandButton action="{!Stats_In}" value="click" reRender="panel2">
    <apex:param name="MS_Item" value="MS_Item_45382" assignTo="{!MS_Item}" />
</apex:commandButton>
1
  • 1
    I was trying to reproduce this but was not able to. But yes need to have reRender even if it is some dummy element. Aug 8, 2017 at 6:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.