• SurjenduK
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 2
    Replies
Code:
<apex:page>

<script src="/soap/ajax/12.0/connection.js" type="text/javascript"></script>
<script>
function setupPage(search)
{
var output = document.getElementById("output");
try
{
sforce.connection.login("surkuila@gmail.com", "pooja1234$lFX0WCCdn6h1ut6WoxWkwUB0c");
var queryResult = sforce.connection.query("Select Id, name from Lead where name like '%" + search + "%'");
layoutResults(queryResult, output);
}
catch(error)
{
queryFailed(error, output);
}
}

function queryFailed(error, out)
{
out.innerHTML = "<font color=red>An error has occurred:</font> <p>" + error;
}

function layoutResults(queryResult, out)
{
if (queryResult.size > 0)
{
var output="";
var records = queryResult.getArray('records');
for (var i = 0; i < records.length; i++)
{
var lead = records[i];
output += lead.Id + " " + lead.Name + "<BR>";
}
out.innerHTML = output;
}
else
{
out.innerHTML = "No records matched.";
}
}

</script>


<div class="bNext">
<div class="withFilter">
<div class="rolodex">
<a href="javascript:setupPage('A')" class="listItem"><span class="listItemPad">A</span></a>
<a href="javascript:setupPage('B')" class="listItem"><span class="listItemPad">B</span></a>
</div>
</div>
</div>

<body>
<div id="output"></div>
</body>

</apex:page>

 The above code does a ajax request on a hyperlink click and dumps the output data. I want to build a <apex:dataTable> instead of just dumping the data. How do I achieve this?

A basic question " How to do complex ajax request within VisualForce". All the examples in the pdf and books are simple and does not reflect the actual complexity of the ajax problems we face. Any help from gurus? My earlier example has everything in HTML covered in just <apex:page>. The apex:page is the only tag i am using to make it a visualforce page.

I eventually want it to be a VF page and not SControl. So please dont give me suggestions to use S-Control.

How to do complex ajax request within VisualForce?


Code:
<apex:page id="myPage">
<apex:form id="myForm">
<apex:pageBlock>

<apex:outputPanel>
<apex:inputText id="accName"></apex:inputText>
<apex:actionSupport event="onkeydown" rerender="detail">
<apex:param name="val" value="document.getElementById('{!$Component.accName}').value"/>
</apex:actionSupport>
</apex:outputPanel>


<apex:outputPanel id="detail">
<apex:actionStatus >
<apex:facet name="stop">
<apex:outputText value="{!$CurrentPageReference.parameters.val}"></apex:outputText>
</apex:facet>
</apex:actionStatus>
</apex:outputPanel>

</apex:pageBlock>
</apex:form>
</apex:page>

Whenever i enter some value in the textfield the detail panel renders
document.getElementById('{!$Component.accName}').value

I want the value of

document.getElementById('{!$Component.accName}').value
 and not
document.getElementById('{!$Component.accName}').value.

Also the ajax function in not getting called in every key stroke. It just gets called only once at first.
How to solve this?
Code:
<apex:page controller="SamePageController" tabstyle="Lead" standardStylesheets="false" >
<script type="text/javascript">
function grabExName()
{
var ex = document.getElementById("exname").value;
alert(ex);
}
</script>


<apex:sectionHeader title="Create Extranets">
<apex:form>

<apex:pageBlock>

<apex:pageBlockSection columns="3" title="Extranet Information">

<apex:outputLabel style="font-weight:bold;" value="Extranet Name" for="exname"/>
<apex:inputText id="exname" required="true" onkeydown="grabExName()"></apex:inputText

</apex:pageBlockSection>

</apex:pageBlock>
</apex:form>
</apex:sectionHeader>

</apex:page>

 What am I doing wrong here? I get an error which says document.getElementById("exname") does not exist. How do i refer the inputText id i created?

How to go about the following usecase?

I have one text field in a VF page. The use case is when the user types something in the text field I have to rerender the page(with an additional outputText whose value is what the user is typing) with every key stroke.

For example is the user types Sales I have to rerender the page with each key stroke of Sales to http://sales.forcewiki.net

How do i do this?

This is my idea: Please validate:

I will capture each keystroke of the user using javascript and use ajax to re-render the page by passing the value of the keystroke.
What do u guys say? Any better solution is welcome.
How do i enable visualforce? I dont see the pages item when i go to AppSetup. Also I dont see any checkbox called Developer Mode in Setup->My personal Information -> Personal Information.

I have 2 ids. The first Id i created in January. When I log in using that id i can see the pages etc, but when i login using the id i created today i dont see any pages.
Folks,

Does anyone know how to troubleshoot when I get an error that states:

Visualforce Error
An internal server error has occurred

This just started happening randomly after I commented out 2 lines that do nothing important within my custom controller...

Also, another thing I did was launch the system log so I could debug but I don't know if that is related to this server error problem...

Please advise...Thanks
Code:
<apex:page controller="SamePageController" tabstyle="Lead" standardStylesheets="false" >
<script type="text/javascript">
function grabExName()
{
var ex = document.getElementById("exname").value;
alert(ex);
}
</script>


<apex:sectionHeader title="Create Extranets">
<apex:form>

<apex:pageBlock>

<apex:pageBlockSection columns="3" title="Extranet Information">

<apex:outputLabel style="font-weight:bold;" value="Extranet Name" for="exname"/>
<apex:inputText id="exname" required="true" onkeydown="grabExName()"></apex:inputText

</apex:pageBlockSection>

</apex:pageBlock>
</apex:form>
</apex:sectionHeader>

</apex:page>

 What am I doing wrong here? I get an error which says document.getElementById("exname") does not exist. How do i refer the inputText id i created?