function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nabemarunabemaru 

Error of Using Browser Technologies in Visualforce - Part 3

Hello,

Now I am tryying to build of title samples.
http://wiki.apexdevnet.com/index.php/Using_Browser_Technologies_in_Visualforce_-_Part_3

But I have some page Error, please tell me how to build that sample code.

  • Create some folders and populate them with documents.
I could do this.

  • Download the Flex swf from here and create a new static resource named FlexTree using the swf file.
I could get swf file and upload this file as a new static resource.

  • Cut and paste the full controller listing into the controller editor.
I could create this apex class.

  • Create a new Visualforce page called, well, anything you like actually. This sample is not dependent on the name of the page.
  • Cut and paste the full page listing below into the new page.
Maybe we should add </script> in line 68.

But I can not save this page.
Because I have some error like this,

Error: Unknown property 'MapValue.name'

Someone knows how to do, please tell me.

Thanks.
JimRaeJimRae
Well, I haven't exactly figured out the problem yet, but I do get the same error as you do.
I have narrowed it down to an issue with the nested list in the myFolder class.
Each myFolder has  list of Documents embedded in it.  appears that apex can't extract the fields out of the embedded list.
I wrote a little test class, which can pull the data correctly, so I know it is in there.  Each of my folders had a list of documents in it, and my test class could loop through the myfolders and then for each loop through the document list, and reference the items by their labels (like the Document Name).
I would be curious if anyone has used this wrapper class style implementation with a nested list in another implementation.
 
Now I am curious.. hope we can figure it out!!
nabemarunabemaru
Thank you for your replying.

I am continuously trying to get folder by apex code, but I can not succeed in that.
If something is figured out, I will post.

Thank you
Dan BakerDan Baker
I get the same error message and can't figure out how to resolve it either.  Unfortunately, all the methods to create a tree structure seem to be above me and the samples that are available I can't get to work in my environment. . .can somebody give us a simpler way to do this or at least a complete example that works?
dchasmandchasman
FYI I pinged the owner of the example to provide some assistance here - stay tuned.
JimRaeJimRae
I was able to get the sample working, if I recall, there was a typo in a variable reference from the flash object, the original had name, and it was supposed to be Name, here are my page and controller code (you still need to create the static resource of the flash object):

PAGE:
Code:
<apex:page controller="docController" id="DocumentTreeViewPage">

<script>
var jsFolders = [];
var flexApp;
var docId, sfolderId, dfolderId, btnMove;

function getMyApp(appName) {
  if (navigator.appName.indexOf("Microsoft") != -1) {
    return window[appName];
  } else {
    return document[appName];
  }
}

function flexIsReady() {
  flexApp = getMyApp("FlexTree");
  flexApp.initApp(jsFolders);
}

function moveDocument(moveData) {
  docId.value = moveData.docId;
  sfolderId.value = moveData.sfolderId;
  dfolderId.value = moveData.dfolderId;
  btnMove.click();
}

</script>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
id="FlexTree" width="282" height="421"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
  <param name="movie" value="{!$Resource.FlexTree}" />
  <param name="quality" value="high" />
  <param name="bgcolor" value="#869ca7" />
  <param name="allowScriptAccess" value="sameDomain" />
  <embed src="{!$Resource.FlexTree}" quality="high" bgcolor="#869ca7"
    width="282" height="421" Name="FlexTree" align="middle"
    play="true"
    loop="false"
    quality="high"
    allowScriptAccess="sameDomain"
    type="application/x-shockwave-flash"
    pluginspage="http://www.adobe.com/go/getflashplayer">
  </embed>
</object>


<apex:repeat id="folderData" value="{!folders}" var="fldr">
  <script> jsFolder = { name:"{!fldr.name}", id:"{!fldr.id}", docs:[], type:"folder" }; </script>
  <apex:repeat value="{!fldr.docs}" var="doc">
    <script> jsFolder.docs.push( { name:"{!doc.name}", id:"{!doc.id}", type:"document" } ); </script>
  </apex:repeat>
  <script> jsFolders.push(jsFolder); </script>
</apex:repeat>


<apex:form id="moveDocForm">
  <apex:inputHidden id="docId" value="{!myDocId}"/>
  <apex:inputHidden id="sfolderId" value="{!mySfolderId}"/>
  <apex:inputHidden id="dfolderId" value="{!myDfolderId}"/>
  <apex:commandButton action="{!moveDoc}" value="Move" id="btnMove" style="display: none" />
  <script>
    docId = document.getElementById("{!$Component.docId}");
    sfolderId = document.getElementById("{!$Component.sfolderId}");
    dfolderId = document.getElementById("{!$Component.dfolderId}");
    btnMove = document.getElementById("{!$Component.btnMove}");
    </script>
</apex:form>
</apex:page>

 

Controller:
Code:
public class docController {

  public class myFolder {
    private String name;
    private String id;
    private list< Document> docs = new List< Document>();
    public List<Document> getDocs(){return new List<Document>(docs); }
  public String getName() { return name; }
    public String getId() { return id; }
  }

  private Map<String, myFolder> folders = new Map<String, myFolder>();
  private String my_DocId;
  private String my_SfolderId;
  private String my_DfolderId;

  public String getMyDocId() { return my_DocId; }
  public String getMySfolderId() { return my_SfolderId; }
  public String getMyDfolderId() { return my_DfolderId; }

  public void setMyDocId(String id) { my_DocId = id; }
  public void setMySfolderId(String id) { my_SfolderId = id; }
  public void setMyDfolderId(String id) { my_DfolderId = id; }

  public String moveDoc() {
    Document doc = [Select Id, FolderId From Document Where Id = :my_DocId];
    doc.FolderId = my_DfolderId;
    update doc;
    return null;
  }

  public List<myFolder> getFolders() {
    List<Folder> thefolders = [Select Folder.id, Folder.name, Folder.type From Folder Where Folder.Type = :'Document'];
    for (Folder fldr : thefolders) {
      myFolder mfldr = new myFolder();
      mfldr.name = fldr.name;
      mfldr.id = fldr.id;
      folders.put(fldr.name, mfldr);
      List<Document> docs = [Select Id, Name From Document Where FolderId = :mfldr.id];
      for (Document doc : docs) {
        mfldr.docs.add(doc);
      }
    }   
    return new List<myFolder>(folders.values());
  }
}

 


Dan BakerDan Baker
Thank you!  That works great!  Finally - I'm able to get one of these trees to work correctly.