+ Start a Discussion
TechnosTechnos 

Show the title of Label Dynamically

How to show or hide  the label on selection of Dropdown list my code is this

 

<apex:page controller="GenerateCaseNumber" >
<apex:form >
   <apex:pageblock title="GenerateCaseNumber" >
         <apex:pageBlockSection showHeader="false" >
      <apex:selectList required="true" multiselect="false" size="1" label="Case(s)"  value="{!selectedValue}"  >
       <apex:actionSupport event="onchange" action="{!GenerateCaseNumber}" reRender="detail"/>
       <apex:selectOptions value="{!CaseTypeOption }"/>
       </apex:selectList>
             <div>
             <apex:outputPanel id="detail" title="Cases">
             <table>
             <tr>
              <apex:outputLabel title="Case Number" ></apex:outputLabel>
             </tr>
             <td>
              <apex:outputLabel value="{!TestFinalCaseNumber}"></apex:outputLabel>
              </td>
              <td>
              </td>
              </table>
             </apex:outputPanel>
            
             </div>
             </apex:pageBlockSection>
             </apex:pageblock>
             </apex:form>
</apex:page>

 

 

 

public with sharing class GenerateCaseNumber
{
    public string selectedvalue {get;set;}
    public CaseType__c objCaseType;
    public Apcase__c objApcase;
    public string TestFinalCaseNumber{get;set;}   
    public string TestCaseNumber {get;set;}
    string CaseNumber = null;
   
    public GenerateCaseNumber ()
     {
       objcaseType = new CaseType__c ();
       objApcase= new Apcase__c();
    }
  
    public  List<selectOption> CaseTypeOption
     {
         get
         {
             List<selectOption> CaseTypeName =new List<selectOption>();
             CaseTypeName.add(new selectOption('None', 'None'));
             for (CaseType__c cn :[select  Name , CaseTypeName__c from CaseType__c])
             CaseTypeName.add(new selectOption(cn.ID, cn.CaseTypeName__c));
             return CaseTypeName;
         }
         private set;
     }
     public PageReference GenerateCaseNumber()
     {
         string casetypeId = selectedValue;
         string DesignatorCode;
         objcaseType = [select  Name,DesignatorCode__c  from CaseType__c where ID =:casetypeId  ];
         DesignatorCode = objcaseType.DesignatorCode__c;
         Date objDate = Date.today(); //returns current date
         integer CurrentYear = objDate.Year(); // Returns year from the date (Return type integer)
       
        string trimyear =string.valueof(CurrentYear);  //Convert int to String
        string strtrimyear =  trimyear.substring(2, 4); // returns subtring from year
        string LikeDesignatorCode  = '';
        LikeDesignatorCode = DesignatorCode  + strtrimyear + '-';
       
        string LikeCondition = LikeDesignatorCode + '%';
        if([ SELECT Name,CaseNo__c FROM Apcase__c WHERE CaseNo__c  like :LikeCondition ORDER BY CaseNo__c  DESC LIMIT 1].Size()>0)
        {
             objApcase = [ SELECT Name,CaseNo__c FROM Apcase__c WHERE CaseNo__c  like :LikeCondition ORDER BY CaseNo__c  DESC LIMIT 1];
             CaseNumber  = objApCase.CaseNo__c;
       
        string strOnlyCaseDigit = CaseNumber.RemoveStart(LikeDesignatorCode );
      
         string Combineconcatinate = '';

        for(integer i = 0 ; i<strOnlyCaseDigit.length();i++)
        {
          string concatinate = strOnlyCaseDigit.substring(i,i+1);
          if( concatinate == '0')
          {
            Combineconcatinate = concatinate + Combineconcatinate ;
          }
          else
          {
            break;
          }
        }
       
        TestCaseNumber  = Combineconcatinate ;
        integer intOnlyCaseDigit = integer.Valueof(strOnlyCaseDigit);
        integer incrementCaseDigit = intOnlyCaseDigit +1;
        string strincrementCaseDigit  = string.valueof(incrementCaseDigit );
       
        TestFinalCaseNumber = DesignatorCode  + strtrimyear + '-'+Combineconcatinate  + strincrementCaseDigit; 
        }
        else
        {
        TestFinalCaseNumber = LikeDesignatorCode +'000001';
        }
    
         return null;
     }

}

 

But pbm is on selection of any case type I am getting casNumber in label but not getting the title " Case Number :" by

  <apex:outputLabel title="Case Number" ></apex:outputLabel> this.

 

Please tell me how to achiev  this type of functionality.

 

Regards

Raman

Avidev9Avidev9
Can you try to explain this again ?
TechnosTechnos

Actually my requirment is simple I just want to show  one label just above the CaseNumber like if I select any casetype from drop down than

outpout be like this

 

Case Number

THP13-0001

 

I am getting this number  "THP13-0001" automatically on the selection of dropdown but how to show this label Case Number above the THP13-0001

I guess now its clear

 

Regards

Raman

 

 

Avidev9Avidev9
<table>
   <tr>
      <td>      
           <apex:outputLabel title="Case Number" ></apex:outputLabel>
       </td>
   </tr>
<tr> <td> <apex:outputLabel value="{!TestFinalCaseNumber}"></apex:outputLabel> </td> </tr> </table>

 

TechnosTechnos

no, I tried this also

Avidev9Avidev9
This works! Make sure you are copying the HTML properly
Here is screenshot of the HTML http://awesomescreenshot.com/0371ilec51
TechnosTechnos

Avi, My requirment is like show this thing

 

CaseNumber

12345

 

Dynamically on the selection of case type not on page load. But its not showing on the selection 'CaseNumber' and 12345 is coming which is autogenerated.

Avidev9Avidev9

I am not sure what you want to say!

But probably you want to display only when there is value. Well that is a condition away I guess

 

<table>
   <tr>
      <td>      
           <apex:outputLabel title="Case Number" rendered="{!TestFinalCaseNumber != NULL || TestFinalCaseNumber !=''}"></apex:outputLabel>
       </td>
   </tr>
<tr> <td> <apex:outputLabel value="{!TestFinalCaseNumber}"></apex:outputLabel> </td> </tr> </table>
nbknbk

Hello,

 

Can you try with following code.

 

<table>
   <tr>
      <td>      
           <apex:outputLabel title="Case Number" rendered="{!IF(TestFinalCaseNumber !=null  &&  TestFinalCaseNumber!='',true,false)}"></apex:outputLabel>
       </td>
   </tr>
   <tr>
       <td>
           <apex:outputLabel value="{!TestFinalCaseNumber}"></apex:outputLabel>
       </td>
   </tr>
   
</table>