0

I have the following VisualForce page. I have a picklist with the name Tip_studija__c. The pickist can have the values 'redni' or 'izredni'. I want to achieve the following: when I choose the value 'izredni' the button shows and when I click on the value 'redni' the button hides. That button is labeled as Samoplacnik.

My code does not achieve this and I do not know where is the problem.

<apex:page controller="CustomStudentController">
<apex:form id="form1">
  <apex:pageBlock id="mainSection" title="Nov Student">
     <apex:pageBlockSection columns="1">
        <apex:inputField value="{!Student.Name}"/>
        <apex:inputField value="{!Student.Priimek__c}"/>
        <apex:inputField value="{!Student.Letnik__c}"/>
        <apex:inputField value="{!Student.Naslov__c}"/>
        <apex:inputField value="{!Student.Datum_rojstva__c}"/>
        <apex:inputField value="{!Student.Naziv_fakultete__c}"/>
        <apex:inputField value="{!Student.Studijski_program__c}"/>
        <apex:inputField value="{!Student.Tip_studija__c}" rendered="{!IF(Student.Tip_studija__c == 'izredni', false, true )}">
            <apex:actionSupport event="onchange" rerender="placnik" />
        </apex:inputField>
        <apex:selectcheckboxes id="btnSpl" layout="pagedirection">
           <apex:selectOption id="Placnik" itemValue="Samoplacnik" itemLabel="Samoplacnik" />
        </apex:selectcheckboxes>
        <apex:pageBlock id="vsi" title="Vsi studenti">
           <apex:pageBlockTable value="{!students}" var="wrapper">
              <apex:column value="{!wrapper.Name}"/>
              <apex:column value="{!wrapper.Priimek__c}"/>
              <apex:column value="{!wrapper.Naslov__c}"/>
              <apex:column value="{!wrapper.Datum_rojstva__c}"/>
              <apex:column value="{!wrapper.Naziv_fakultete__c}"/>
              <apex:column value="{!wrapper.Studijski_program__c}"/>
              <apex:column value="{!wrapper.Letnik__c}"/>
              <apex:column value="{!wrapper.Tip_studija__c}"/>
              <apex:column > 
        <apex:commandButton action="{!deleteStudentRecordById}" value="del" reRender="mainSection"> 
        <apex:param name="studentId" value="{!wrapper.id}"/> 
        </apex:commandButton> 
        </apex:column> 
        </apex:pageBlockTable>
       </apex:pageBlock>
        <apex:commandButton action="{!SaveRecord}" value="Save" id="theButton" reRender="mainSection"/>
    </apex:pageBlockSection>
   </apex:pageBlock>
  </apex:form>
 </apex:page>
0
  1. Try enclosing the button code in a outputpanel and try to rerender that.

  2. If it still doesn't work, check if you have any required fields on the page, which might be preventing the page to rerender due to invalid form. If this is the case, you will have to enclose the picklist and button code within a actionRegion

  3. Also, add 'apex:pageMessages' tag at the top of the page to check for any errors.

  • Hi Hemant! Thanks for the answer. Yes, as I saw that is the problem, all of the input fields of my custom object are required. I tried to put the picklist and the button code within an actionRegion but it does not hide and no error appears. – user911 Sep 21 '17 at 10:39
  • Try to rerender the pageMessage block too when u change the picklist. This link might help u more. salesforce.stackexchange.com/questions/32721/… – Hemant Jain Sep 21 '17 at 10:51
  • Thanks! I tried that but it still does not show any error message. – user911 Sep 21 '17 at 11:31
  • You tried adding the button inside the outputpanel and rerendering the outputpanel instead of the button? – Hemant Jain Sep 21 '17 at 13:04
  • Yes, I tried that and no change. – user911 Sep 21 '17 at 13:19

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.