I am looking for some technique like search form or form filter.
This is a reference .
It is a hotel finding website.
My question is here, how to use coldfusion to create this kind of searching form with ajax?
Please give me some idea or tips , i will appreciate with you assist !
I have just get some idea on ajax search form with text.
<form>
Search: <input type="text" name="search">
<input type="button" value="Search">
</form>
<cfdiv bind="url:movieresults.cfm?search={search}">
</cfdiv>
In general terms, a search form in CF has the same basic concept as a search form in any other format: you have a form wherein you allow the user to supply search criteria and you have some collection of data to search against. So, you see the actual search form itself is only but a small part of searching. You need to construct the data object you will search against and you need to build the pieces to add to that collection (if necessary) and maintain it. Tossing in the Ajax interface will only complicate matters so I'd recommend you stick with a basic search HTML form and once you've mastered submitting a search, doing the search through your data collection and returning that collection to the user in the form of a useful results page...only then should you consider modifying it to run with an Ajax engine.
A good place to start for how to work with cfindex and cfsearch (Coldfusion's tags that create the data collection and to search against that collection) would be found here.
Walking before running, grasshopper. If you encounter any specific problems, feel free to come back here and we'll see what we can do for you. In the meantime, check out our ColdFusion resources thread. It has a great many links to common CF resources that all CF devs, beginners to experts, need/use to help get the job done.
Related
Let's imagine we have simple data and want to make pagination of it. It's not hard to do, simple _GET var with page number others doctrine with offset will allow us to do it in easy way, BUT How should it look like in search page? Let me explain.
For example we have simple route with /search url. Where we have form for our search. When use input string we user POST method on same page and will get result. Simple enough but if we add pagination here it become a problem with storing "inputed string".
If we store in session on search query it will be solution BUT... it's not. Why? User input search string - get result with pagination (here search string already in session) after that leave the page (or close browser, or left to another page). When he will return data from session will show him 'result of old query'...
So question is, what is the best practice for such situation? I want simple search query + pagination of it but if user left page - clear result.
Using POST instead of GET for search query is kinda unusual and not really safe. Since search query operations are read-only you should use GET to access/get the data. POST is used for updating or creating resources.
And how you will go back/forward in the pagination (using browser's buttons)? You always will be getting an alert box. AND you cannot share/bookmark the search query url.
BTW to answer your question, sessions and hidden input fields would be the way to go. You also can use a combination of get and post
When should I use GET or POST method? What's the difference between them?
I have a performance issue using Symfony2 Form Component,
I'm using this component to create a form which contains 300 checkbox(s). This form must be flexible (The checkbox(s) should be created on a SET_DATA event using a given data tree.
I'm also using Subscribers to make my form flexible.
The problem:
The form generation took an average of 900 ms (which is a substantial amount of time given the input size)
Binding my form took much more time (an average of 1sec)
Assumptions:
The propertyPathMapper is taking too much time to create paths and look for the right one to get error messages on validation.
My Question:
In the case of the PropertyPath issue, do you know how to fix it? If it's not, any ideas on how to optimize my form?
Our Code:
I created a github Gist > https://gist.github.com/2867617
data.array is the data format we are using to generate our search form. (the tree can have many sub levels & is created from our database)
SearchType.php is our main Search Type
The other classes we are using are helping us to iterate on and generate all the search criteria elements.
PS: We are using the 2.0.15 version of Symfony2 ,
Thanks,
You can solve first problem by caching the generated form html with Memcache. Remember to invalidate the cache index after saving the form.
With the second problem Use a profiler to check what is taking so long, it may be Doctrine hydration issue.
My session data is being saved in my form as expected.
However, when I run a sort on any column of my results, my form session values are cleared.
I am calling in my search form through en element as it's used on specific locations of the site.
Does anyone know why pagination is clearing out my session? Is this standard Cake?
The paginator sort elements are simply a link generated by the paginator and won't consider any of your form data. The first thing you need to make sure that you're doing is tell the paginator to include any URL paramters for the current page in the url it generates. Put this anywhere in the view before you call any of the $paginator functions.
$paginator->options(array('url' => $this->passedArgs));
Secondly, make sure that your search parameters are being included in the URL. It sounds like they probably aren't. I just answered another question on the best practices of search result URLs here: CakePHP Search Results Best Practices
I solved this:
CakePHP session ID path or other method to share the results of a url - recommendations welcome
Many services (eg, bit.ly) will shorten URLs, even those w/ GET data,
since that's just part of the URL.
Do any work w/ POST data? In some cases (eg, certain types of CBOE
option quotes), you must POST data to get the information you want.
The service might bring up a page (eg, shorten.com/foo) that has:
<form action="/url/to/post/to">
<input type="hidden" name="var1" value="val1">
...
<input type="submit" value="SUBMIT">
</form>
where the /url/to/post/to and var1/val1/etc are set by the person
creating the shortened URL. It would also say:
"By pressing the button below, you will post this data to this URL:
/url/to/post/to: [list of hidden fields and values]"
Seems useful and easy to do... has anyone done it?
OK, this seems to have degenerated into a moral argument. I'll assume the answer is no, no one has already done this.
I see two big problems:
Who is going to copy / paste the form (often generated by javascript) - Regular users? It would only be open to people with enough technical competence to do it. And it may not do not have the intended effects since some data may be in cookies or held server-side.
Also, post requests are not usually considered an open api for anyone to use. Usually, data is built up over a series of steps with possible use of cookies and login information. Websites are not going to be happy with letting people delete their account or bypass certain pages that are in the normal process flow.
I'm looking for a strategy for managing links within articles. The body of the article is saved in a database and pulled during page assembly. What all should be saved in the database to easily define and manage links?
Some purists believe that markup should NEVER be stored in the database. Some believe its ok in moderation. But to me, the notion of a link is almost inseparable from its html markup.
Is there a better, more succinct way of representing a link in an article (in a database) than simply embedding "anchor text"?
One idea I've kicked around involves embedding just enough markup to semantically describe areas of interest, and in a different table, map those notions to actual URLs. All encounters of a particular notion get wrapped with the link.
<p>Here is an example of a
<span class="external-reference semantic-web">semantic</span>
approach to link management.</p>
A table then might associate the URL of the article and the key class of 'semantic-web' to a URL like http://en.wikipedia.org/wiki/Semantic_Web
<p>Here is an example of a <span class="external-reference semantic-web">
semantic</span>
approach to link management.</p>
Things I like about this approach is that all my URLs are in one location in the database. I could technically change or remove links without touching the body of the article. I have very good class names for CSS.
I don't like having another table to maintain, and another step/phase in render time. It could slow down response time.
Are there any other strategies out there that provide superior link management?
You may want to look at templating (such as Smarty for PHP).
I agree that markup shouldn't normally be held in the database.
However, you might also consider implementing a "pointer" concept, where at each link, you break your storage of the page, add a pointer in the table to the link, then a pointer in the link table to the next segment of content for the page. (I have no idea how complicated that would be - just an idea.)
Or look at how various CMS tools handle the idea. Some just put everything in the database as one big block of text, while others rely on templating, and others may do something else entirely (like object-oriented environments such as Plone).
There are a few attempts to do this that I have seen.
One way to do this is through URL redirects. You can implement a logic component on the server that will interpretate what the URL is requesting rather than a path to the content.
Another attempt is that the links orginally set to a reference value [which can be looked up in a database], and is requested at runtime/generation.
Regardless, you will have to reference the material that you wish to link to with some sort of identifier.