• Chopa
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies

Hello,

 

I want to make a report in a visualforce page (with a controller extension) without using the the report wizard / builder tool. I am not using it because I have some requirements like being able to display or hide columns, adding a watermark and so on.

 

I was wondering what is the best approach to do some grouping in a visualforce page. I want to group the details (proposal lines) by a custom field  "Category__c".  Should I go with an <apex:repeat> per category ? is <apex:dataTable> a better option ?

 

The report will be rendered as a pdf, so is there a tag I should go or not go with ? Like a tag that may not be handled well with the pdf page break. And lastly, is there a way, in my visualforce page, to add a page break (when rendered in pdf).

 

Thanks,

 

Chopa

 

  • November 18, 2010
  • Like
  • 0

Hi,

My goal is this: In a custom Case layout, when a user clicks on an image, a lookup window shows up and the user can select one of the items displayed in it. These items have a child releationship with the Case object. Upon selection, the lookup window closes and a record is inserted. The record contains the CaseID and the childID that is assigned to the item selected in the lookup window.

To achieve this, I am using 2 vfpages, one of them contains the image that will be displayed in the Case layout. The other is my lookup page.

Here's the code of my "image" vfpage:

<apex:page StandardController="Case" extensions="RWW_Case_PunchClock_Controller" id="myApexPageId">
   
    <apex:form >             
        <apex:actionFunction name="punchIn" action="{!punchIn}" rerender="myApexPageId">
           <apex:param name="vCaseChargeTypeId" assignTo="{!oCaseChargeTypeId}" value=""/>
        </apex:actionFunction>
        <img id="imgClockPunch" src="{!$Resource.PunchIn}" onclick="javascript&colon; openLookup()"/>
    </apex:form>
   
    <script language = "javascript">
         var win;   
       
        function openLookup()
        {
            win = window.open('/apex/rww_case_charge_type_lookup', 'Select a charge type', 'height=500, width=300');
            win.focus();
        }
       
        function setSelectedChargeType(myVal)
        {           
            vCaseChargeTypeId = myVal;
            punchIn();
            win.close();
        }      
     
    </script>
</apex:page>

Here's my Image Controller code:

public class RWW_Case_PunchClock_Controller
{
    public string oCaseId {get; private set; }
    public string oCaseChargeTypeId { get; set; }   
       
    public RWW_Case_PunchClock_Controller(ApexPages.StandardController controller)
    {
        Case objCase = (Case)controller.getRecord();
        oCaseId = objCase.Id;        
    }

    public RWW_Case_PunchClock_Controller()
    {       
    }
    
    public PageReference punchIn()
    {
        Case_Charge_Type__c[] objChargeType = [Select id, Billable__c, Rate__c from Case_Charge_Type__c where Id =: oCaseChargeTypeId];

        Case_Time_Detail__c objTimeDetail = new Case_Time_Detail__c(Case__c = oCaseId, Billable__c = objChargeType[0].Billable__c,Rate__c = objChargeType[0].Rate__c,
                                                                    Start_Date__c = DateTime.Now(), Case_Charge_Type__c = objChargeType[0].Id);
        insert objTimeDetail;
        oPunchState = '';
        return null;
    }    
}



Here's my "lookup" vfpage code:

<apex:page Controller="RWW_Case_Charge_Type_Controller" showHeader="false" id="fullPage">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockTable value="{!ChargeTypes}" var="items">
                    <apex:column headerValue="Charge Type Name" >
                        <apex:commandLink value="{!items.Name}" action="{!setId}" >
                            <apex:param name="selectedChargeTypeId" assignTo="{!selectedId}" value="{!items.Id}" />
                        </apex:commandLink>
                    </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
    <script language="javascript">
        function SendValueToParent()
        {                    
            window.top.opener.setSelectedChargeType("{!selectedId}");
            close();
        }
       
        if("{!selectedId}" != null && "{!selectedId}" != "")
        {
            SendValueToParent();
        }
    </script>
</apex:page>

Here's my Lookup Controller code:

public class RWW_Case_Charge_Type_Controller
{
    public List<Case_Charge_Type__c> ChargeTypes { public get; private set; }
    public string selectedId{ get; set; }
    
    public RWW_Case_Charge_Type_Controller()
    {
        ChargeTypes = [Select id, name from Case_Charge_Type__c];
    }
    
    public PageReference setId()
    {
    selectedId = ApexPages.currentPage().getParameters().get('selectedChargeTypeId');
    return null;
    }
}


The selected id is retrieved succesfully from my image vfpage. My problem is that even if I assign its value to my javascript-controller variable, the value is not given properly to the controller when invoking my punchIn method. In fact, the controller is not receiving the value at all, like it was never set.

I also tried to use a static variable inside a global class to pass my selectedChildId from my lookup controller to my "image controller". But again, the static variable is not set according to my Image controller.

Also, I am using a custom lookup page instead of invoking the built-in javascript method "openLookup" because in the future, I intend to add some validations/code to the onClose/onOpen event of the lookup page.

My question: Do you know why my selected "Child Id" is not being passed to my imageController once I have retrieved it in my vfpage ?

Thanks for reading my post

  • September 27, 2010
  • Like
  • 0

Hi,

My goal is this: In a custom Case layout, when a user clicks on an image, a lookup window shows up and the user can select one of the items displayed in it. These items have a child releationship with the Case object. Upon selection, the lookup window closes and a record is inserted. The record contains the CaseID and the childID that is assigned to the item selected in the lookup window.

To achieve this, I am using 2 vfpages, one of them contains the image that will be displayed in the Case layout. The other is my lookup page.

Here's the code of my "image" vfpage:

<apex:page StandardController="Case" extensions="RWW_Case_PunchClock_Controller" id="myApexPageId">
   
    <apex:form >             
        <apex:actionFunction name="punchIn" action="{!punchIn}" rerender="myApexPageId">
           <apex:param name="vCaseChargeTypeId" assignTo="{!oCaseChargeTypeId}" value=""/>
        </apex:actionFunction>
        <img id="imgClockPunch" src="{!$Resource.PunchIn}" onclick="javascript&colon; openLookup()"/>
    </apex:form>
   
    <script language = "javascript">
         var win;   
       
        function openLookup()
        {
            win = window.open('/apex/rww_case_charge_type_lookup', 'Select a charge type', 'height=500, width=300');
            win.focus();
        }
       
        function setSelectedChargeType(myVal)
        {           
            vCaseChargeTypeId = myVal;
            punchIn();
            win.close();
        }      
     
    </script>
</apex:page>

Here's my Image Controller code:

public class RWW_Case_PunchClock_Controller
{
    public string oCaseId {get; private set; }
    public string oCaseChargeTypeId { get; set; }   
       
    public RWW_Case_PunchClock_Controller(ApexPages.StandardController controller)
    {
        Case objCase = (Case)controller.getRecord();
        oCaseId = objCase.Id;        
    }

    public RWW_Case_PunchClock_Controller()
    {       
    }
    
    public PageReference punchIn()
    {
        Case_Charge_Type__c[] objChargeType = [Select id, Billable__c, Rate__c from Case_Charge_Type__c where Id =: oCaseChargeTypeId];

        Case_Time_Detail__c objTimeDetail = new Case_Time_Detail__c(Case__c = oCaseId, Billable__c = objChargeType[0].Billable__c,Rate__c = objChargeType[0].Rate__c,
                                                                    Start_Date__c = DateTime.Now(), Case_Charge_Type__c = objChargeType[0].Id);
        insert objTimeDetail;
        oPunchState = '';
        return null;
    }    
}



Here's my "lookup" vfpage code:

<apex:page Controller="RWW_Case_Charge_Type_Controller" showHeader="false" id="fullPage">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockTable value="{!ChargeTypes}" var="items">
                    <apex:column headerValue="Charge Type Name" >
                        <apex:commandLink value="{!items.Name}" action="{!setId}" >
                            <apex:param name="selectedChargeTypeId" assignTo="{!selectedId}" value="{!items.Id}" />
                        </apex:commandLink>
                    </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
    <script language="javascript">
        function SendValueToParent()
        {                    
            window.top.opener.setSelectedChargeType("{!selectedId}");
            close();
        }
       
        if("{!selectedId}" != null && "{!selectedId}" != "")
        {
            SendValueToParent();
        }
    </script>
</apex:page>

Here's my Lookup Controller code:

public class RWW_Case_Charge_Type_Controller
{
    public List<Case_Charge_Type__c> ChargeTypes { public get; private set; }
    public string selectedId{ get; set; }
    
    public RWW_Case_Charge_Type_Controller()
    {
        ChargeTypes = [Select id, name from Case_Charge_Type__c];
    }
    
    public PageReference setId()
    {
    selectedId = ApexPages.currentPage().getParameters().get('selectedChargeTypeId');
    return null;
    }
}


The selected id is retrieved succesfully from my image vfpage. My problem is that even if I assign its value to my javascript-controller variable, the value is not given properly to the controller when invoking my punchIn method. In fact, the controller is not receiving the value at all, like it was never set.

I also tried to use a static variable inside a global class to pass my selectedChildId from my lookup controller to my "image controller". But again, the static variable is not set according to my Image controller.

Also, I am using a custom lookup page instead of invoking the built-in javascript method "openLookup" because in the future, I intend to add some validations/code to the onClose/onOpen event of the lookup page.

My question: Do you know why my selected "Child Id" is not being passed to my imageController once I have retrieved it in my vfpage ?

Thanks for reading my post

  • September 27, 2010
  • Like
  • 0