• rahul2526
  • NEWBIE
  • 25 Points
  • Member since 2010

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies

The page below is working absolutely fine...

What I am doing here is that:

 

On pressing the enter key on Text control (Red bolded) i am calling javascript functn which is calling send() from controller class.

 

controller class function is..

 

public PageReference send(){

 //some code

return null;

}

 

 this functn is redirecting on same page...

now other script function setFocusOnLoad() is making Text control to be focussed on page load....

 

when I use showHeader property of <apex:page> to "TRUE"...

all things run fine...

 

but as soon as i disable header i.e make showHeader property to "False"

 

cursor doesnot get focussed to Text control

 

 

<apex:page id="thePage" showHeader="true" sidebar="false" controller="Test">
<script>
function setFocusOnLoad() {

var txt=document.getElementById(text1)
    txt.value=''
  txt.focus()
}

</script>

<script type="text/javascript">
 
function callSend(e){

if(e){
e = e
} else {
e = window.event
}

if(e.which){
var keycode = e.which
} else {
var keycode = e.keyCode
}

if(keycode == 13) {
 

var send=document.getElementById(sendText)
            send.click()
           
            return false
}
else{
return true
}
}


</script>
<apex:form>
    <apex:inputTextarea id="messengerText" value="{!messageText}" readonly="true" cols="100" rows="10" disabled="{!visible2}"/><br>
        <apex:actionPoller action="{!refresh}" reRender="messengerText" interval="5"/>
   
   
 
   
        <apex:outputLabel value="Enter text here"/>
           <apex:inputTextarea id="Text" value="{!text}" cols="70" disabled="{!visible2}" onkeydown="callSend(event)"/><br>
   
           <script> var text1 = '{!$Component.Text}';</script>

   
   
           <apex:commandButton id="send" action="{!send}" value="Send"/>
        <script> var sendText = '{!$Component.send}';</script>
<apex:form>
</apex:page>

 

 

 

Plz tell me the solution of this...

because I don't want the header to be shown on my page and at the same time I want to focus Text control(TextArea) on page load..

 

 

Thank you

 

 

Hi...

 

I am trying to set focus to a specified textbox through its controller class(as it is requirement) ...

 

For this in asp we have like "Page.RegisterStartupScript()"...

for eg..

 

private void SetFocus(String controlID)
{
  // Build the JavaScript String
  System.Text.StringBuilder sb = new System.Text.StringBuilder();
  sb.Append("<script language='javascript'>");
  sb.Append("document.getElementById('");
  sb.Append(controlID);
  sb.Append("').focus()");
  sb.Append("</script>")
 
  // Register the script code with the page.
  Page.RegisterStartupScript("FocusScript", sb.ToString());
}

 

 

Is there any method in apex in Force.com to register a javascript on current page through apex code...

 

please reply asap...

 

Thank you!!!

Hello to all.....

 

well I am trying to use Ajax to refresh a control which is inside a table(HTML tags)...

like:

 

<table>

  <tr>

        <td><apex:inputTextArea id="TextArea" value="{!someText}"/></td>

        <apex:actionPoller action="{!refresh}" reRender="TextArea" interval="5"/>

  </tr>

</table>

 

 

 

 

when I use above code..my TextArea control doesnot refresh after 5 sec...

but if I remove the html tags only...then the code executes fine....

 

can someone clear me wether Ajax is supported within html tags or not...

 

and if not so what can I do to format(in tabular format) my visualforce page.

 

Thanks!!!

 

Hello all....

 

I am trying to create a web messenger  using Visualforce page and apex controller class...

 

I am using ajax to refresh my textArea control...how can i achieve that thing..

 

As to refresh basically I'll use

 

<apex:inputTextArea  id="msg" value="{!getMessage}" >

<apex:actionSupport onevent=""/> 

</apex:inputTextArea> 

 

What should be this onevent attribute value so that my control gets refreshed after 5 seconds. 

 

OR

 

if you have some other idea please help me out!!!

Thanks!!! 

The page below is working absolutely fine...

What I am doing here is that:

 

On pressing the enter key on Text control (Red bolded) i am calling javascript functn which is calling send() from controller class.

 

controller class function is..

 

public PageReference send(){

 //some code

return null;

}

 

 this functn is redirecting on same page...

now other script function setFocusOnLoad() is making Text control to be focussed on page load....

 

when I use showHeader property of <apex:page> to "TRUE"...

all things run fine...

 

but as soon as i disable header i.e make showHeader property to "False"

 

cursor doesnot get focussed to Text control

 

 

<apex:page id="thePage" showHeader="true" sidebar="false" controller="Test">
<script>
function setFocusOnLoad() {

var txt=document.getElementById(text1)
    txt.value=''
  txt.focus()
}

</script>

<script type="text/javascript">
 
function callSend(e){

if(e){
e = e
} else {
e = window.event
}

if(e.which){
var keycode = e.which
} else {
var keycode = e.keyCode
}

if(keycode == 13) {
 

var send=document.getElementById(sendText)
            send.click()
           
            return false
}
else{
return true
}
}


</script>
<apex:form>
    <apex:inputTextarea id="messengerText" value="{!messageText}" readonly="true" cols="100" rows="10" disabled="{!visible2}"/><br>
        <apex:actionPoller action="{!refresh}" reRender="messengerText" interval="5"/>
   
   
 
   
        <apex:outputLabel value="Enter text here"/>
           <apex:inputTextarea id="Text" value="{!text}" cols="70" disabled="{!visible2}" onkeydown="callSend(event)"/><br>
   
           <script> var text1 = '{!$Component.Text}';</script>

   
   
           <apex:commandButton id="send" action="{!send}" value="Send"/>
        <script> var sendText = '{!$Component.send}';</script>
<apex:form>
</apex:page>

 

 

 

Plz tell me the solution of this...

because I don't want the header to be shown on my page and at the same time I want to focus Text control(TextArea) on page load..

 

 

Thank you

 

 

Hi...

 

I am trying to set focus to a specified textbox through its controller class(as it is requirement) ...

 

For this in asp we have like "Page.RegisterStartupScript()"...

for eg..

 

private void SetFocus(String controlID)
{
  // Build the JavaScript String
  System.Text.StringBuilder sb = new System.Text.StringBuilder();
  sb.Append("<script language='javascript'>");
  sb.Append("document.getElementById('");
  sb.Append(controlID);
  sb.Append("').focus()");
  sb.Append("</script>")
 
  // Register the script code with the page.
  Page.RegisterStartupScript("FocusScript", sb.ToString());
}

 

 

Is there any method in apex in Force.com to register a javascript on current page through apex code...

 

please reply asap...

 

Thank you!!!

Hello to all.....

 

well I am trying to use Ajax to refresh a control which is inside a table(HTML tags)...

like:

 

<table>

  <tr>

        <td><apex:inputTextArea id="TextArea" value="{!someText}"/></td>

        <apex:actionPoller action="{!refresh}" reRender="TextArea" interval="5"/>

  </tr>

</table>

 

 

 

 

when I use above code..my TextArea control doesnot refresh after 5 sec...

but if I remove the html tags only...then the code executes fine....

 

can someone clear me wether Ajax is supported within html tags or not...

 

and if not so what can I do to format(in tabular format) my visualforce page.

 

Thanks!!!

 

Hello all....

 

I am trying to create a web messenger  using Visualforce page and apex controller class...

 

I am using ajax to refresh my textArea control...how can i achieve that thing..

 

As to refresh basically I'll use

 

<apex:inputTextArea  id="msg" value="{!getMessage}" >

<apex:actionSupport onevent=""/> 

</apex:inputTextArea> 

 

What should be this onevent attribute value so that my control gets refreshed after 5 seconds. 

 

OR

 

if you have some other idea please help me out!!!

Thanks!!!