• Tux
  • NEWBIE
  • 35 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 10
    Replies

I have a custom field defined in my Opportunity standard object. It is a checkbox. When I view the details for a particular opportunity, if the checkbox is selected, I do not wish to show the custom button on the layout. However, if it is not selected, I want to show the button and execute apex code, the source of which is a VF page. 

 

How is that possible? Tried to edit the layout, but could not find anything there.

  • February 01, 2012
  • Like
  • 0

I want to knw whether a checkbox was ticked or not.

 

Something like Object.fieldName.isChecked().

 

How do I do that?

  • January 23, 2012
  • Like
  • 0

I want to call a method from within JS (jQuery to be more specific). This method needs a String parameter and I cant seem to be able to pass this parameter. Here is the relevant bits of code.

 

The line in bold is how I am calling the apex method. VF code: 

 

<apex:page controller="DynaTreeHierarchyController" >
<apex:includeScript value="{!URLFOR($Resource.dynatree, '/jquery/jquery.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.dynatree, '/jquery/jquery-ui.custom.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.dynatree, '/jquery/jquery.cookie.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.dynatree, '/src/jquery.dynatree.js')}"/>
<apex:stylesheet value="{!URLFOR($Resource.dynatree, '/src/skin/ui.dynatree.css')}"/>

<script type="text/javascript">

$(function(){
    var dataurl;
    var space = ' ';
    // Variant 1:
    /*$("span.dynatree-edit-icon").live("click", function(e){
        //alert("Edit " + $.ui.dynatree.getNode(e.target));
    });*/
    $("#tree").dynatree({
        onActivate: function(node) {
            $("#info").text("You activated " + node.data.id);
        },
        onRender: function(node, nodeSpan) {
            $(nodeSpan).find('.dynatree-icon')
               .before('<span class="dynatree-icon dynatree-edit-icon"></span>');
        },
        //Variant 2:
        onClick: function(node, f){
            if($(f.target).hasClass("dynatree-edit-icon")){
                $("#info").text("You clicked " + node + ",  url=" + node.data.id);
            }
        },
      children: [
            {title: "Item 1", isFolder: true, id: "http://Item1.com"},
            {title: "Folder 2", isFolder: true, id: "http://Item2.com", 
            children: [
                {title: "Sub-item 2.1", id: "http://sub-item21.com"},
                {title: "Sub-item 2.2", id: "http://sub-item22.com"}
            ]
        },
            {title: "Item 3", id: "http://Item3.com"}
      ],
      dnd: {          
      onDragStart: function(node) {
        $("#info").text("tree.onDragStart " + node.data.id);
        return true;
      },
      onDragStop: function(node) {
        // This function is optional.
        $("#info").text("tree.onDragStop " + node.data.id);
      },
      autoExpandMS: 1000,
      preventVoidMoves: true, // Prevent dropping nodes 'before self', etc.
      onDragEnter: function(node, sourceNode) {
        $("#info").text("tree.onDragEnter " + node.data.id);
        return true;        
      },
      onDragOver: function(node, sourceNode, hitMode) {
        $("#info").text("tree.onDragOver " + node + space + sourceNode + space + hitMode);
        // Prevent dropping a parent below its own child
        if(node.isDescendantOf(sourceNode)){
          return false;
        }
        // Prohibit creating childs in non-folders (only sorting allowed)
        //        if( !node.isFolder && hitMode == "over" )
        //          return "after";
      },
      onDrop: function(node, sourceNode, hitMode, ui, draggable) {
        /** This function MUST be defined to enable dropping of items on
         * the tree.
         */
        $("#info").text("tree.onDrop " + node.data.id + space+ sourceNode + space + hitMode);
        sourceNode.move(node, hitMode);
        myFunc('test this method');
        dataurl = node.data.id;
        // expand the drop target
        //sourceNode.expand(true);
      },
      onDragLeave: function(node, sourceNode) {
        /** Always called if onDragEnter was called.
         */
        $("#info").text("tree.onDragLeave " + node + sourceNode);
      }
    }
    })
});

</script>
<style>

</style>
<div id="tree"></div>
<div id="info"></div>

<!-- 
END JAVASCRIPT, BEGIN APEX CODE
-->
    <apex:form >
        <apex:messages />
        <apex:actionFunction name="myFunc" action="{!IWantToDebug}">
            <apex:param name="param1" value=""/>
        </apex:actionFunction>
    </apex:form>
</apex:page>

 

The controller code:

public with sharing class DynaTreeHierarchyController {

    public void IWantToDebug() {
        String para = ApexPages.CurrentPage().getParameters().get('param1');
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, 'Msg ' + para));
        System.debug('Called from JS without para ' + para);
    }
}

 

What am doing incorrectly?

 

  • January 18, 2012
  • Like
  • 0

I wish to access a List ("alist" in the below attribute) that is passed in a custom component. I am having trouble accessing it. Here is my custom component:

<apex:component controller="testController" >
    <apex:attribute name="title" description="This is the title of the component" type="String" required="true"/>
    <apex:attribute name="count" description="This is the count of the component" type="String" required="true"/>
    <apex:attribute name="color" description="Color to set as background" type="String" required="true"/>
    <apex:attribute name="alist" description="A list of values" type="List" required="false"/>
</apex:component>

 

Here is my controller:

public with sharing class testController {

    public String title {get; set;}
    public List<String> alist {get; set;}
    public List<cValue> customWrap {get; set;}
    
    public testController() {
        System.debug('Title of ::'+title);
        System.debug('Entering custom controller.');
        customWrap = new List<cValue>();
        System.debug('alist in testcontroller::'+alist);
    }
    
    public class cValue {
        public String con {get; set;}
        public Integer value {get; set;}
    
        public cValue(String country, Integer val) {
            con = country;
            value = val;
        }
    }
}

And this is how I call my custom component in the VF page:

 

<c:TestSubPageBlock title="Test" count="3" color="#342145" alist="{!ListOfValues}"></c:TestSubPageBlock>

 

  • December 12, 2011
  • Like
  • 0

Hello,

I am making a custom component. One of the attributes that I pass to this custom component is a map and use it inside repeat tags. However, I get an error such as this:

 

Error: Wrong type for attribute <c:testsubpageblock amap="{!amap}">. Expected Map, found VisualforceMap	

 I read the Component Reference and it says that only one dimensional data structures are supported. May I know why there is such a restriction? Also, is there any workaround? Googling doesnt help a lot. It seems components arent much written about in tutorials and what not.

 

Thanks.

  • December 09, 2011
  • Like
  • 0

Hello,

I was wondering if you guys have any idea on how to align the numbers that you see in the image below, perfectly under one another. Right now, I use '/t' in my controller and '&nbsp;' on my VF page. Both are used inside <pre> tags. However, its not a very elegant solution. I need to use different amoutns of tabspaces depending upon the length. 

 

  • December 07, 2011
  • Like
  • 0

Hi,

I am displaying the contents of a Map on a Visualforce page. This map is sorted by first putting the contents in a list, and then putting the list contents in a Map, as answered in another thread on this board. Here are my code snippets:

 

<apex:pageBlockSection columns="2" collapsible="true" title="{!title}" rendered="{!IF(condition >0,true,false)}" >            
            <apex:repeat value="{!MapSortedInCode}" var="count">
              <apex:pageBlockSectionItem>{!count}</apex:pageBlockSectionItem>
              <apex:pageBlockSectionItem>{!MapSortedInCode[count]}</apex:pageBlockSectionItem>
            </apex:repeat>
          </apex:pageBlockSection>

 

public Map<String, Integer> sortMap(Map <String, Integer> someMap){
        
        Map<String, Integer> newMap = new Map<String, Integer>();
         
        List<String> aList = new List<String>();
        aList.addAll(someMap.keySet());
        aList.sort();
        System.debug('aList::'+aList);
        
        for(String a: aList){
         Integer value = someMap.get(a);
         newMap.put(a, value);
        }
        
        return newMap;
    }

 These are the outputs of the Debug Log:

|DEBUG|Before sorting Map: {Armenia=1, Belgium=1}
|DEBUG|aList::(Armenia, Belgium)
|DEBUG|After sorting Map: {Armenia=1, Belgium=1} 

However, on the visualforce page, the Map is not displayed in a sorted manner. Its neither ascending, nor descending, or alphabetical, or sorted by value. Can anyone tell me what the issue is?

 

Thanks a lot.

  • December 06, 2011
  • Like
  • 0

I have a custom field defined in my Opportunity standard object. It is a checkbox. When I view the details for a particular opportunity, if the checkbox is selected, I do not wish to show the custom button on the layout. However, if it is not selected, I want to show the button and execute apex code, the source of which is a VF page. 

 

How is that possible? Tried to edit the layout, but could not find anything there.

  • February 01, 2012
  • Like
  • 0

I want to knw whether a checkbox was ticked or not.

 

Something like Object.fieldName.isChecked().

 

How do I do that?

  • January 23, 2012
  • Like
  • 0

I want to call a method from within JS (jQuery to be more specific). This method needs a String parameter and I cant seem to be able to pass this parameter. Here is the relevant bits of code.

 

The line in bold is how I am calling the apex method. VF code: 

 

<apex:page controller="DynaTreeHierarchyController" >
<apex:includeScript value="{!URLFOR($Resource.dynatree, '/jquery/jquery.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.dynatree, '/jquery/jquery-ui.custom.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.dynatree, '/jquery/jquery.cookie.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.dynatree, '/src/jquery.dynatree.js')}"/>
<apex:stylesheet value="{!URLFOR($Resource.dynatree, '/src/skin/ui.dynatree.css')}"/>

<script type="text/javascript">

$(function(){
    var dataurl;
    var space = ' ';
    // Variant 1:
    /*$("span.dynatree-edit-icon").live("click", function(e){
        //alert("Edit " + $.ui.dynatree.getNode(e.target));
    });*/
    $("#tree").dynatree({
        onActivate: function(node) {
            $("#info").text("You activated " + node.data.id);
        },
        onRender: function(node, nodeSpan) {
            $(nodeSpan).find('.dynatree-icon')
               .before('<span class="dynatree-icon dynatree-edit-icon"></span>');
        },
        //Variant 2:
        onClick: function(node, f){
            if($(f.target).hasClass("dynatree-edit-icon")){
                $("#info").text("You clicked " + node + ",  url=" + node.data.id);
            }
        },
      children: [
            {title: "Item 1", isFolder: true, id: "http://Item1.com"},
            {title: "Folder 2", isFolder: true, id: "http://Item2.com", 
            children: [
                {title: "Sub-item 2.1", id: "http://sub-item21.com"},
                {title: "Sub-item 2.2", id: "http://sub-item22.com"}
            ]
        },
            {title: "Item 3", id: "http://Item3.com"}
      ],
      dnd: {          
      onDragStart: function(node) {
        $("#info").text("tree.onDragStart " + node.data.id);
        return true;
      },
      onDragStop: function(node) {
        // This function is optional.
        $("#info").text("tree.onDragStop " + node.data.id);
      },
      autoExpandMS: 1000,
      preventVoidMoves: true, // Prevent dropping nodes 'before self', etc.
      onDragEnter: function(node, sourceNode) {
        $("#info").text("tree.onDragEnter " + node.data.id);
        return true;        
      },
      onDragOver: function(node, sourceNode, hitMode) {
        $("#info").text("tree.onDragOver " + node + space + sourceNode + space + hitMode);
        // Prevent dropping a parent below its own child
        if(node.isDescendantOf(sourceNode)){
          return false;
        }
        // Prohibit creating childs in non-folders (only sorting allowed)
        //        if( !node.isFolder && hitMode == "over" )
        //          return "after";
      },
      onDrop: function(node, sourceNode, hitMode, ui, draggable) {
        /** This function MUST be defined to enable dropping of items on
         * the tree.
         */
        $("#info").text("tree.onDrop " + node.data.id + space+ sourceNode + space + hitMode);
        sourceNode.move(node, hitMode);
        myFunc('test this method');
        dataurl = node.data.id;
        // expand the drop target
        //sourceNode.expand(true);
      },
      onDragLeave: function(node, sourceNode) {
        /** Always called if onDragEnter was called.
         */
        $("#info").text("tree.onDragLeave " + node + sourceNode);
      }
    }
    })
});

</script>
<style>

</style>
<div id="tree"></div>
<div id="info"></div>

<!-- 
END JAVASCRIPT, BEGIN APEX CODE
-->
    <apex:form >
        <apex:messages />
        <apex:actionFunction name="myFunc" action="{!IWantToDebug}">
            <apex:param name="param1" value=""/>
        </apex:actionFunction>
    </apex:form>
</apex:page>

 

The controller code:

public with sharing class DynaTreeHierarchyController {

    public void IWantToDebug() {
        String para = ApexPages.CurrentPage().getParameters().get('param1');
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, 'Msg ' + para));
        System.debug('Called from JS without para ' + para);
    }
}

 

What am doing incorrectly?

 

  • January 18, 2012
  • Like
  • 0

I wish to access a List ("alist" in the below attribute) that is passed in a custom component. I am having trouble accessing it. Here is my custom component:

<apex:component controller="testController" >
    <apex:attribute name="title" description="This is the title of the component" type="String" required="true"/>
    <apex:attribute name="count" description="This is the count of the component" type="String" required="true"/>
    <apex:attribute name="color" description="Color to set as background" type="String" required="true"/>
    <apex:attribute name="alist" description="A list of values" type="List" required="false"/>
</apex:component>

 

Here is my controller:

public with sharing class testController {

    public String title {get; set;}
    public List<String> alist {get; set;}
    public List<cValue> customWrap {get; set;}
    
    public testController() {
        System.debug('Title of ::'+title);
        System.debug('Entering custom controller.');
        customWrap = new List<cValue>();
        System.debug('alist in testcontroller::'+alist);
    }
    
    public class cValue {
        public String con {get; set;}
        public Integer value {get; set;}
    
        public cValue(String country, Integer val) {
            con = country;
            value = val;
        }
    }
}

And this is how I call my custom component in the VF page:

 

<c:TestSubPageBlock title="Test" count="3" color="#342145" alist="{!ListOfValues}"></c:TestSubPageBlock>

 

  • December 12, 2011
  • Like
  • 0

Hello,

I am making a custom component. One of the attributes that I pass to this custom component is a map and use it inside repeat tags. However, I get an error such as this:

 

Error: Wrong type for attribute <c:testsubpageblock amap="{!amap}">. Expected Map, found VisualforceMap	

 I read the Component Reference and it says that only one dimensional data structures are supported. May I know why there is such a restriction? Also, is there any workaround? Googling doesnt help a lot. It seems components arent much written about in tutorials and what not.

 

Thanks.

  • December 09, 2011
  • Like
  • 0

Hi,

I am displaying the contents of a Map on a Visualforce page. This map is sorted by first putting the contents in a list, and then putting the list contents in a Map, as answered in another thread on this board. Here are my code snippets:

 

<apex:pageBlockSection columns="2" collapsible="true" title="{!title}" rendered="{!IF(condition >0,true,false)}" >            
            <apex:repeat value="{!MapSortedInCode}" var="count">
              <apex:pageBlockSectionItem>{!count}</apex:pageBlockSectionItem>
              <apex:pageBlockSectionItem>{!MapSortedInCode[count]}</apex:pageBlockSectionItem>
            </apex:repeat>
          </apex:pageBlockSection>

 

public Map<String, Integer> sortMap(Map <String, Integer> someMap){
        
        Map<String, Integer> newMap = new Map<String, Integer>();
         
        List<String> aList = new List<String>();
        aList.addAll(someMap.keySet());
        aList.sort();
        System.debug('aList::'+aList);
        
        for(String a: aList){
         Integer value = someMap.get(a);
         newMap.put(a, value);
        }
        
        return newMap;
    }

 These are the outputs of the Debug Log:

|DEBUG|Before sorting Map: {Armenia=1, Belgium=1}
|DEBUG|aList::(Armenia, Belgium)
|DEBUG|After sorting Map: {Armenia=1, Belgium=1} 

However, on the visualforce page, the Map is not displayed in a sorted manner. Its neither ascending, nor descending, or alphabetical, or sorted by value. Can anyone tell me what the issue is?

 

Thanks a lot.

  • December 06, 2011
  • Like
  • 0