zf2 How to achieve auto-complete when use fieldset - zend-framework2

I have a web form generate by using zf2 fieldset, for one of the input field "Company Name" in this case, I want achieve auto-complete where the source for the select option comes from the database.
Thank for any advice in advance,
Frank

Here is one way to do it.
Make this fieldset launch a jquery function when you type in
This function will fetch data from an api controller in json
The controller asks for the data and returned them as json
one fetch you just have to display the data
You can do this using the jquery typeahead
Here is an example
Here is a way to implement it
Hope this will help you

Related

can we write javascript code in jsp which is of with struts html tag library

this is phani kumar,
Actually, i am writing one page to show product details. In that i written code to display the
productid list in jsp page with the help of and tags
. but the main problem is, based on the selection of productid, i trying to show the product details(productname, productcost, productstock..like).But i am facing problems to work this.
I am trying it with javascript, but because of struts html taglibrary, i am getting problems here, could u please give me solutions to resolve this problem anyone.
and can anybody tell how to get dropdown selection value into javascript(if we are using tag library in struts)
How are you using javascript to create your view? You should be able to use
<logic:iterate>
to traverse your product collection, then
<bean:write .../>
to display information from each product.
<html:select>
will create a dropdown in your form. Use
<html:option>, <html:options>, or <html:optionsCollection>
to populate each item in the dropdown.

Struts2 create dropdown dymamically based on first dropdown value in Struts2 using hibernate

Hi I am using Struts2 and hibernate now in my jsp I have Two dropdown ,on selection of first drop it should call a function and retrive the values for second drop down from the database
Please help
Well you have number of options here and some of them are
user struts2-jquery plugin which comes with this feature where you can create two dependable select.
user simple jquery with JSON (struts2 plugin) and use ajax.
i will prefer second approach which is much more flexible.create a custom JS function with help from jquery and when use select first option from drop down call your action methods which will send JSON data based on the selected values and use JQuery build in JSON parsing mechanism to parse the content and fill second drop-down.
a simple Google search will give you a number of results.

Using Ruby/Rails To Programmatically Post Form Data To Another Site

I'm trying to figure out a way to automate posting data on this site which does not have an API and thankfully not a captcha as well.
For example there is a form here => http://www.austinchronicle.com/gyrobase/EventSubmission
By examining the form I can figure out that the Name text box is setup as follows......
<input type="text" name="Name" id="EventName" value="" class="rejectPipe">
Using Ruby/Rails is there a way I can programmatically POST to the form on that page through the controller or in a rake task?
I sniffed out some links like => http://biodegradablegeek.com/2008/04/how-to-post-form-data-using-ruby/
and that seems to sort of explain the basic premise but what about inserting data into the time control or the drop down select boxes on another site? Or pretty much anything more complicated than inserting a string into an input box
Your best bet is to use something like Mechanize. I've written a blog post on a related subject (uploading data with Mechanize) : http://davidsulc.com/blog/2011/11/13/uploading-data-using-mechanize/
Alternatively, if you want to see the page while information is being entered, you could user Selenium http://davidsulc.com/blog/2011/11/27/automating-web-site-interactions-with-selenium/
You can use Typhoeus
For datetime selects you need conform to Rails protocol. Just pop open the source of the page and look at the names of their elements and use the same structure when posting. Do the same with select boxes

Generate URL client-side for jQuery Grid from json field?

We are using Struts 2 and want a jQuery Grid showing a list of accounts. When a user clicks an account we want to take them to a page specific to that account.
At this point I'm looking for suggestions as to the best way to do this. Currently I'm building a URL server side which I then return but this isn't optimal since I don't have access to <s:url>.
One idea I've had is to combine <s:url> and each row Id on the client side but I haven't found a way to do this. Is there a grid would that allow this? or a better way?
Updated Explanation Attempt:
I am returning a json list to jQuery grid. One column in the grid is a url but I can't build that in the service level. Instead I'd love to have a way to use <s:url> when my json results are returned. Is there anyway to do this?
You cannot use <s:url> client side.
The Struts2-Tags get used serverside
to generate the HTML, so there's
basically no difference if you
construct them yourself or let JSP
construct the HTML.
There's the struts2-jQuery Plugin and with it the jQuery grid plugin. Find out more about it here:
https://code.google.com/p/struts2-jquery/
If you know the actionName and have the ID in the list you're iterating over, you can just code the necessary link yourself (if the object in the list has a getter named getId()):
<a href="http://host:port/webapp/actionName?id=<s:property value='id' />">
Hope that helps, if not please show the code of the page and / or dredefine your question.
There isn't a really straight forward way. Here is the answer to "Struts2 URL buiilding in action for JSON" answered on the struts mailing list:
http://old.nabble.com/Struts2-URL-building-in-action-for-JSON.-td30487914.html
If you get a chance let me know how you implement this.

Two forms submission - one from Menu and one from Body

I am using tiles framework in my application. I have two JSP(body.jsp and menu.jsp) files one is for body and one is for Menu(Left hand side menu). Now i want a single submit button in body which will post the both body and menu data to one action class.
Kindly suggest solution for the above said problem
Thanks in advance.
Either you make the whole page a big form
or you could use JavaScript to collect the values from the other form and set them in hidden fields of the other form as soon as they're entered
or you use JavaScript to construct a URL by collecting the values and don't use forms at all

Resources