• Rani_R
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 11
    Replies
Hi,

I have created a dashboard with two columns and have two VF pages in them. Both these pages share a same controller. I have a button in the first VF page and when it is clicked, i want to rerender a section in the second VF page to display the modified data in the controller.

Could someone please help me in triggering the rerender event in seconf vf page from first one.

Thanks
Dinesh
  • February 20, 2014
  • Like
  • 0

Hi,

 

I am calling a servlet from my apex code, i am getting a pdf stream as response, the whole pdf is available in the response.getBody()... But i dont know how to display the pdf now.

 

Here is what i did

 

public void GetDocument()
    {
        
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        HttpResponse res;
        
        req.setEndpoint('myservlet?docid='+SelDocId);                           
        req.setMethod('GET');
        req.setTimeOut(30000);
        req.setHeader('Cookie',cookieString);
        res = http.send(req);
        pdfData = res.getBody();
    }

 

My VF Page:

 

<script> 
    function showDocument()
    {
        var htmlstr = '<html></head></head><body>sdfsfsdfsdf<object width="400" height="500" type="application/pdf" data="'+docData.value+'"/></body></html>';
        window.frames[0].document.body.innerHTML = htmlstr;          
    }
</script>

<apex:commandbutton action="{!GetDocument}" value="GetDocument" reRenderer="docpanel"/>

 

 <apex:outputpanel id="docpanel">

         <apex:inputHidden id="docData" value="{!pdfData}"/>

         <script>
                   docData = document.getElementById("{!$Component.docData}");
          </script>

 

        <iframe scrolling="true" id="theIframe" onLoad="showDocument()" type="application/pdf"/>
        <object width="400" height="500" type="application/pdf" data="{!pdfData}" id="pdf_content"/>
        <apex:outputtext value="{!pdfData}" id="outputtemp"/>
    </apex:outputpanel> 

 

when my apex method getDocument gets over, the outputPanel docPanel will get re-rendered, thereby calling my javascript method showDocument() which is in onLoad of my iframe...

 

I am trying to put the document inside iframe or in the object.. but it just stays empty, the pdf document is not getting displayed......

 

But in the outputText "outputtemp" the whole pdf is printed as a string, starting as %pdf- ... .............. <EOF>, this confirms i am getting the document.

 

Please help me in displaying the pdf in iframe or in the object tag.... what am i doing wrong here? if there is any workaround also please let me know.

 

 

Thankyou

Rani.

  • March 15, 2011
  • Like
  • 0

Hi,

 

I have a tab "Document Management" and i have associated a VF Login page to this tab.... when user logs in here i call a jsp and i get a  cookie back in my response, which i have to embed in my next requests..

 

When user logs in successfully, i am redirecting to a new VF INDEX page in the same tab.... so i am passin the cookie parameters in the query string to the second page... here i dont have any problems...

 

But if i visit a new tab, say accounts tab or contacts tab and then return to my Document Management tab, the first Login page gets displayed..... I need to know somehow that user has already logged in before, so i have to redirect the user directly to the INDEX page... so where can i put the cookie values that i got in my first login request? is there any session like we have in java or .net that will be persisted always....

 

Also i have a small pageblock in the contacts and accounts detail page.. .so when user goes to contacts tab and selects a contact there, i should know whether the user has already logged in Document management tab, if he has logged in i should display the documents in that paeg block, else i have to ask user to login there....

 

I hope i have explained properly... i want to persist some details like whether user has logged in and his id all those things in session kind of thing...

 

Please help me and let me know how i can achieve this...

 

Thanks and Regards,

Rani.....

  • March 08, 2011
  • Like
  • 0

Hi,

 

When we enter into any contact, below is the default layout,

 

Contacts Detail

 

and below contacts detail there are many pageBlocks like below

 

Opportuniites

Cases

Open Activities

Activity History

Notes and Attatchments..

 

Now i want to add a new pageblock under it like "Documents"... IS THIS POSSIBLE? if possible i prefer it to be a seperate VF Page...so that i can have my controller to populate the data in it by calling a jsp...

 

I saw sControls, but also read it is not allowed to create after march 2010.... i am unclear, please give me some example or a link to help paeg where i can find info about this

 

Please let me know how to do this.

 

Thanks,

Rani

  • March 07, 2011
  • Like
  • 0

Hi,

 

I have a tab named DocumentManagement. and i have a VF Page named loginpage. I have assigned loginpage as content to the DocumentManagement tab..... So when i go to DocumentManagement tab, the loginpage is displayed.

 

when i click on the login button in that page i call a function in my LoginController apex class....

 

I submit the username and password to a jsp page and get an xml back.... if it is success i have to redirect to a newpage.. Below is my code to do that. I have a page named IDM_Index...

 

if(element.nodeValue.equals('Success')){
                      ApexPages.PageReference nextPage = Page.IDM_Index;
                      nextPage.setRedirect(true);
                      return nextPage;

 

It gets successfully redirected to idm_index page, BUT THE PROBLEM I FACE IS, THE SELECTED TAB IS NOT DocumetnManagement, instead now the selected tab is Home... i dont know why it got resetted to home.. i want it to stay in DocumentManagement itself...... Is there any setting i should do for this? PLEASE HELP, THIS IS A MAJOR PROBLEM FOR ME.....

 

Also when i click on login, during the redirection the whole salesforce page is getting refreshed, but instead i want the loginPage alone go blank and come as IDM_Index... Please let me know what i should do? i should use ajax is it?

 

Thanks and Regards,

Rani...

  • March 04, 2011
  • Like
  • 0

Hi,

 

I have two questions, i am trying to figure it out for a long time, please help me.

 

Below is my apex code,

 

public class Dev_Login{
    public String userName {get; set;}
    public String password {get; set;}
    public String outputText {get; set;}
    
    public Dev_Login() {
        
    }    
    
    public void loginFn() {

        Http http = new Http();
        HttpRequest req = new HttpRequest();
        HttpResponse res;
        try {        
            req.setEndpoint('https://www.mywebsite.com/jsp');
            req.setHeader('Content-Type', 'application/x-www-form-urlencoded');      
            req.setMethod('POST');
            String theMessage = 'userId='+userName+'&password='+password;            
            
            req.setBody(theMessage);
            
            res = http.send(req);
            
            outputText = res.getBody();
            
        } catch (Exception e) {
            System.debug('Error'+e);
        }
    }
}

 

 

the response (res.getBody()) will contain a HTML content, i want to display it in the VF Page that contains the login button. How should i do it? i had the below in my vf page

 

<apex:outputpanel >
        <apex:outputtext rendered="true" value="{!outputText}"/>
    </apex:outputpanel>

 

But this just displayed the html content as a string, didnt render it as html.. Please tell me how should i do it?

 

-----------------------------------------------

 

My second question,

 

say if i get an XML in the response in this page (outputText)

i want to redirect to a new VF page where i will use that xml to display something... how should i pass this xml to that new page. that newpage will use a different controller..  so i want to pass this xml to the second page's controller and second page should be displayed... how should i do it.

 

Please help me with these two questions..

 

Thanks,

Rani

  • March 02, 2011
  • Like
  • 0

Hi,

 

I am very new here, i am doing a POC to show our data inside the salesforce website.

 

I will list out what all i have done.

 

1. I created a new app.

2. I created a new tab and a visual source page.

 

Below is the code for my visual source page

 

<apex:page standardController="Account" controller="LoginController">
<apex:pageBlock title="Hello {!$User.FirstName}! Please login">
    <apex:Form >
        <table>
            <tr>
                <td>Username:</td>
                <td><apex:inputField id="userName" value="{!userName}"/></td>                
            </tr>
            <tr>
                <td>Password:</td>
                <td><apex:inputfield id="passWord" value="{!password}"/></td>                
            </tr>
            <tr>
                <td></td>
                <td align="right"><apex:commandButton value="Login" action="{!loginFn}"/></td>
            </tr>
        </table>    
    </apex:Form>
</apex:pageBlock>
</apex:page>

 

 

This is my custom controller


public class LoginController {
    public String userName;
    public String password;
    public LoginController () {
        
    }    
    public void loginFn() {
        
        Http http       = new Http();
        HttpRequest req = new HttpRequest();

        try {        
            req.setEndpoint('http://documentcollaboration.elementfx.com/phpscript/login.php?username='+userName+' &password='+password);
            req.setMethod('POST');
            
            HttpResponse res = http.send(req);
            
        } catch (Exception e) {           
        }
    }    
}

 

When i click on the Login Button, the LoginFn will be called(atleast thats what i hope so)...

 

http://documentcollaboration.elementfx.com/phpscript/login.php?username=Dinesh&password=Dinesh

 

The above link will return an XML like below

 

 <Output><Status>Success</Status><user><username>Dinesh</username><displayname>Dinesh</displayname><email>Dinesh@Dinesh.com</email></user></Output>

Based on the XML i want to display contents accordingly in my visualpage... if the status is success then i want to redirect to an another page, else i want to display an error message.

 

Please help me on how to do this... what should i do.. also is there any error in my apex code or visualforce page?

 

Thanks and Regards,

Rani

  • February 28, 2011
  • Like
  • 0

Hi,

 

I am calling a servlet from my apex code, i am getting a pdf stream as response, the whole pdf is available in the response.getBody()... But i dont know how to display the pdf now.

 

Here is what i did

 

public void GetDocument()
    {
        
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        HttpResponse res;
        
        req.setEndpoint('myservlet?docid='+SelDocId);                           
        req.setMethod('GET');
        req.setTimeOut(30000);
        req.setHeader('Cookie',cookieString);
        res = http.send(req);
        pdfData = res.getBody();
    }

 

My VF Page:

 

<script> 
    function showDocument()
    {
        var htmlstr = '<html></head></head><body>sdfsfsdfsdf<object width="400" height="500" type="application/pdf" data="'+docData.value+'"/></body></html>';
        window.frames[0].document.body.innerHTML = htmlstr;          
    }
</script>

<apex:commandbutton action="{!GetDocument}" value="GetDocument" reRenderer="docpanel"/>

 

 <apex:outputpanel id="docpanel">

         <apex:inputHidden id="docData" value="{!pdfData}"/>

         <script>
                   docData = document.getElementById("{!$Component.docData}");
          </script>

 

        <iframe scrolling="true" id="theIframe" onLoad="showDocument()" type="application/pdf"/>
        <object width="400" height="500" type="application/pdf" data="{!pdfData}" id="pdf_content"/>
        <apex:outputtext value="{!pdfData}" id="outputtemp"/>
    </apex:outputpanel> 

 

when my apex method getDocument gets over, the outputPanel docPanel will get re-rendered, thereby calling my javascript method showDocument() which is in onLoad of my iframe...

 

I am trying to put the document inside iframe or in the object.. but it just stays empty, the pdf document is not getting displayed......

 

But in the outputText "outputtemp" the whole pdf is printed as a string, starting as %pdf- ... .............. <EOF>, this confirms i am getting the document.

 

Please help me in displaying the pdf in iframe or in the object tag.... what am i doing wrong here? if there is any workaround also please let me know.

 

 

Thankyou

Rani.

  • March 15, 2011
  • Like
  • 0

Hi,

 

I have a tab "Document Management" and i have associated a VF Login page to this tab.... when user logs in here i call a jsp and i get a  cookie back in my response, which i have to embed in my next requests..

 

When user logs in successfully, i am redirecting to a new VF INDEX page in the same tab.... so i am passin the cookie parameters in the query string to the second page... here i dont have any problems...

 

But if i visit a new tab, say accounts tab or contacts tab and then return to my Document Management tab, the first Login page gets displayed..... I need to know somehow that user has already logged in before, so i have to redirect the user directly to the INDEX page... so where can i put the cookie values that i got in my first login request? is there any session like we have in java or .net that will be persisted always....

 

Also i have a small pageblock in the contacts and accounts detail page.. .so when user goes to contacts tab and selects a contact there, i should know whether the user has already logged in Document management tab, if he has logged in i should display the documents in that paeg block, else i have to ask user to login there....

 

I hope i have explained properly... i want to persist some details like whether user has logged in and his id all those things in session kind of thing...

 

Please help me and let me know how i can achieve this...

 

Thanks and Regards,

Rani.....

  • March 08, 2011
  • Like
  • 0

Hi,

 

When we enter into any contact, below is the default layout,

 

Contacts Detail

 

and below contacts detail there are many pageBlocks like below

 

Opportuniites

Cases

Open Activities

Activity History

Notes and Attatchments..

 

Now i want to add a new pageblock under it like "Documents"... IS THIS POSSIBLE? if possible i prefer it to be a seperate VF Page...so that i can have my controller to populate the data in it by calling a jsp...

 

I saw sControls, but also read it is not allowed to create after march 2010.... i am unclear, please give me some example or a link to help paeg where i can find info about this

 

Please let me know how to do this.

 

Thanks,

Rani

  • March 07, 2011
  • Like
  • 0

Hi,

 

I have a flex swf object as a static resource and have embedded in my VF Page...

 

I am calling a jsp page and retrieving xml data. Now i want to push this data into my flex swf.. how to do it?

 

I have a function like below in my flex app.

 

public function BuildTree(str:String):void{

        //code....

}

 

also i have exposed this as a externalinterface call by adding the below code

 

ExternalInterface.addCallback("BuildTree", BuildTree);

 

I can call this from a javascript in my VF page and push the xml into it... But since i am getting the xml only during execution of apex code, what should i do? below is my apex code..

 

public void GetData(){

        Http http = new Http();
        HttpRequest req = new HttpRequest();
        HttpResponse res;
        
        req.setEndpoint('www.mysite.com/sendxmldata.jsp?userId='+userName);                           
        req.setMethod('GET');
        req.setTimeOut(30000);
        req.setHeader('Cookie',cookieString);
        res = http.send(req);
        outputText = res.getBody(); 

}

 

I will fire this GetData function on click of a button in my VF Page..

 

This outputText will be a XML, i now want to push this xml into the my flex code by BuildTree function so that my flex app refreshes.... How should i do it?

 

Thanks and Regards,

Dinesh

Hi,

 

I have a tab named DocumentManagement. and i have a VF Page named loginpage. I have assigned loginpage as content to the DocumentManagement tab..... So when i go to DocumentManagement tab, the loginpage is displayed.

 

when i click on the login button in that page i call a function in my LoginController apex class....

 

I submit the username and password to a jsp page and get an xml back.... if it is success i have to redirect to a newpage.. Below is my code to do that. I have a page named IDM_Index...

 

if(element.nodeValue.equals('Success')){
                      ApexPages.PageReference nextPage = Page.IDM_Index;
                      nextPage.setRedirect(true);
                      return nextPage;

 

It gets successfully redirected to idm_index page, BUT THE PROBLEM I FACE IS, THE SELECTED TAB IS NOT DocumetnManagement, instead now the selected tab is Home... i dont know why it got resetted to home.. i want it to stay in DocumentManagement itself...... Is there any setting i should do for this? PLEASE HELP, THIS IS A MAJOR PROBLEM FOR ME.....

 

Also when i click on login, during the redirection the whole salesforce page is getting refreshed, but instead i want the loginPage alone go blank and come as IDM_Index... Please let me know what i should do? i should use ajax is it?

 

Thanks and Regards,

Rani...

  • March 04, 2011
  • Like
  • 0

Hi,

 

I have two questions, i am trying to figure it out for a long time, please help me.

 

Below is my apex code,

 

public class Dev_Login{
    public String userName {get; set;}
    public String password {get; set;}
    public String outputText {get; set;}
    
    public Dev_Login() {
        
    }    
    
    public void loginFn() {

        Http http = new Http();
        HttpRequest req = new HttpRequest();
        HttpResponse res;
        try {        
            req.setEndpoint('https://www.mywebsite.com/jsp');
            req.setHeader('Content-Type', 'application/x-www-form-urlencoded');      
            req.setMethod('POST');
            String theMessage = 'userId='+userName+'&password='+password;            
            
            req.setBody(theMessage);
            
            res = http.send(req);
            
            outputText = res.getBody();
            
        } catch (Exception e) {
            System.debug('Error'+e);
        }
    }
}

 

 

the response (res.getBody()) will contain a HTML content, i want to display it in the VF Page that contains the login button. How should i do it? i had the below in my vf page

 

<apex:outputpanel >
        <apex:outputtext rendered="true" value="{!outputText}"/>
    </apex:outputpanel>

 

But this just displayed the html content as a string, didnt render it as html.. Please tell me how should i do it?

 

-----------------------------------------------

 

My second question,

 

say if i get an XML in the response in this page (outputText)

i want to redirect to a new VF page where i will use that xml to display something... how should i pass this xml to that new page. that newpage will use a different controller..  so i want to pass this xml to the second page's controller and second page should be displayed... how should i do it.

 

Please help me with these two questions..

 

Thanks,

Rani

  • March 02, 2011
  • Like
  • 0

Hi,

 

I am very new here, i am doing a POC to show our data inside the salesforce website.

 

I will list out what all i have done.

 

1. I created a new app.

2. I created a new tab and a visual source page.

 

Below is the code for my visual source page

 

<apex:page standardController="Account" controller="LoginController">
<apex:pageBlock title="Hello {!$User.FirstName}! Please login">
    <apex:Form >
        <table>
            <tr>
                <td>Username:</td>
                <td><apex:inputField id="userName" value="{!userName}"/></td>                
            </tr>
            <tr>
                <td>Password:</td>
                <td><apex:inputfield id="passWord" value="{!password}"/></td>                
            </tr>
            <tr>
                <td></td>
                <td align="right"><apex:commandButton value="Login" action="{!loginFn}"/></td>
            </tr>
        </table>    
    </apex:Form>
</apex:pageBlock>
</apex:page>

 

 

This is my custom controller


public class LoginController {
    public String userName;
    public String password;
    public LoginController () {
        
    }    
    public void loginFn() {
        
        Http http       = new Http();
        HttpRequest req = new HttpRequest();

        try {        
            req.setEndpoint('http://documentcollaboration.elementfx.com/phpscript/login.php?username='+userName+' &password='+password);
            req.setMethod('POST');
            
            HttpResponse res = http.send(req);
            
        } catch (Exception e) {           
        }
    }    
}

 

When i click on the Login Button, the LoginFn will be called(atleast thats what i hope so)...

 

http://documentcollaboration.elementfx.com/phpscript/login.php?username=Dinesh&password=Dinesh

 

The above link will return an XML like below

 

 <Output><Status>Success</Status><user><username>Dinesh</username><displayname>Dinesh</displayname><email>Dinesh@Dinesh.com</email></user></Output>

Based on the XML i want to display contents accordingly in my visualpage... if the status is success then i want to redirect to an another page, else i want to display an error message.

 

Please help me on how to do this... what should i do.. also is there any error in my apex code or visualforce page?

 

Thanks and Regards,

Rani

  • February 28, 2011
  • Like
  • 0