Copy link to clipboard
Copied
Is there a way to 'redirect' the output stream to a certain element on the browser?... I have all the elements on the screen (template, editable zone with a grid that have some cells populated), but, the final step is to fill a cell with some data taken from a CFOUTPUT QUERY... and when I use this tag, the output allways goes to the top of the screen...there is a way to preselect where is goint to occur the CFOUTPUT sream to write?
Copy link to clipboard
Copied
This question is going to need some more explanation and|or some code (hopefully clear, concise code) for understanding!
<cfoutput...> doesn't output to a stream in the usual sense of the word.
CFML process on the server, it is completely processed before anything is delivered to a browser. So by the time an elements are being drawn on a client screen ColdFusion is done and moved on to some other job.
Copy link to clipboard
Copied
Thanks for your help. very kind of you to try to help someone that you does not know...
The idea is: desing a page, place some elements on it (I use a lot of grids to distribute space) at design time (like any fixed html code). Then, when the user logs-in, add some information taken from the database, and put it on a zone that is pre-determined to use it.
The following code does it: show a fixed page distributed with a grid, and when the user log-in, it show some new book titles that wold be relevant to him. I used (as a sample) a database that comes (hopefully) in all ColdFusion installs (I use MX7) CFBooks
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<cfif IsDefined("form.Submit")>
<cfset Link="" />
<cfquery name="Resumen" datasource="CFBookClub">
SELECT Books.title
FROM Books
</cfquery>
<table border="0" cellpadding="3" cellspacing="3">
<tr>
<td bgcolor="#FFFF99">Title</td>
</tr>
<cfoutput query="Resumen" maxrows="6">
<tr>
<td>#Resumen.Title#</td>
</tr>
</cfoutput>
</table>
</cfif>
<cfform name="form1" method="post" action=""><em><strong>User name:
<cfinput type="text" name="text" value="whatever">
<cfinput type="submit" name="Submit" value="Submit" label="submit">
</strong></em></cfform>
<table width="557" height="291" border="1">
<tr>
<td width="292">Place some FIXED content here:<br>
Text, pictures, whatever.... in design time... </td>
<td width="249">(This space wold be used for DYNAMIC data get from a database, to be filled when the user logs-in (on the submit event)) </td>
</tr>
<tr>
<td height="150">Place some other content here... in design time </td>
<td> </td>
</tr>
</table>
<p> </p>
<p> </p>
</body>
</html>
When the form is displayed the first time it loads, it shows the populated grid, but, when the user press the "subtmit" button, the output goes to the upper corner of the browser. so, the question is: What kind of construction should I have to use to populate with data certain zone, form, grid (whatever).. I thisk that is a solved problem, because all the CMS sends data taken from a database (like text for a blog) and put on certain element...
Thanks..
Copy link to clipboard
Copied
I found this way to redirect the output of a CFOutPut to a certain cell on a table... but, I dont like so much the solution... As far as you know, there is a better way to do it? XLMS? CSS? in wich way wold you looking for?
Thanks for your time...
(This code draw a grid on the screen, and when the user click the 'submit' button, gets some data from the DB and put on a specific cell)
<body>
<cfquery name="getNames"
datasource="cfdocexamples">
SELECT * FROM Employee
</cfquery>
<cfparam name="PageNum_getNames" default="1">
<cfset MaxRows_getNames=10>
<cfset StartRow_getNames=Min((PageNum_getNames-1)*MaxRows_getNames+1,Max(getNames.RecordCount,1))>
<cfset EndRow_getNames=Min(StartRow_getNames+MaxRows_getNames-1,getNames.RecordCount)>
<cfset TotalPages_getNames=Ceiling(getNames.RecordCount/MaxRows_getNames)>
<table width="721" height="397" border="1">
<tr>
<td width="300" height="127"><cfform name="form1" method="post" action="">
<cfinput type="submit" name="Generar" value="Generar">
</cfform>
</td>
<td width="405">
<cfif IsDefined("form.Generar")>>
<cfform name="TablaEstudios" method="post" action="">
<table border="1" cellpadding="2" cellspacing="2">
<tr>
<td>Emp_ID</td>
<td>FirstName</td>
<td>LastName</td>
</tr>
<cfoutput query="getNames" startRow="#StartRow_getNames#" maxRows="#MaxRows_getNames#">
<tr>
<td>#getNames.Emp_ID#</td>
<td>#getNames.FirstName#</td>
<td>#getNames.LastName#</td>
</tr>
</cfoutput>
</table>
</cfform></td>
</cfif>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</body>
Copy link to clipboard
Copied
You questions seem to be showing a real misunderstanding of the sever-client relationship of ColdFusion.
ColdFusion runs on the server, the entire request is processed on the server and any response you care to build is completely built. Then this entire response is returned to the web server which forwards it back to the client which renders the response. This is the basic flow which can become a bit muddled if one applies something like AJAX or Flash|Flex to the mix. But in reality it is still request and responses. Just with Ajax several requests and responses can be going on at the same time.
So what are you really trying to do here? Return HTML? DHTML? XML? SMS? Do you want it rendered in a browser, phone, flash player something else? Do you want to do something asynchronously?
But at the root of all of these posibilities is a client makes a request to the ColdFusion server. ColdFusion receives the requests runs ALL the CFML to build the response, returns it and waits for the next request.