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

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.

Related

zf2 How to achieve auto-complete when use fieldset

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

extend rich:select / h:select to have multiple selections

Is it possible to extend rich:select or h:selectOneMenu to enable multiple selection? I am looking for a jsf component which looks like the jQuery Chosen plugin.
The component should let me select multiple options from the drop down.
Please note that I can not use h:selectManyMenu or list box because of the specific requirement.
Note: just saw the tags field below the description box while posting a question. I am looking exactly for the same functionality, except that I want a JSF component, not a js plugin.
Any suggestion is highly appreciated. Thanks in advance.
I would use that jQuery Chosen plugin and do something like this:
use jQuery to apply it to your select
use jQuery to get the selected data
pass the data to the backing bean via a hidden input field
There may be 'pure JSF' ways but it looks like more work. If you find something interesting let me know.

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.

Howto extend a form via ajax depending on select

I have a form with a country select. The form should be extended with new input fields depending on the selected country.
Most of the tutorials i found on google are for ajax submits after filling a forum.
Can somebody recommend a tutorial/howto on howto extend a form via ajax on a select change?
Use something like this. Of cousre url, country_data, and custom_part must be handled according your app. And the returned data comes from your app, better without layout, only the part what you want to add.
$.get("url", country_data, function(returned_data){ $(".custom_part").html(returned_data) })

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

Resources