Grails Calendar plugin issue - string 'struct' in value field - grails

I am trying to use Grails Calendar plugin - https://grails.org/plugin/calendar for getting a date picker. The way I am using this is
<calendar:resources/>
<calendar:datePicker name="startDate" value="${prePopulatedValue}" dateFormat="%Y-%m-%d"/>
Calendar is rendered properly but when I submit the form, the value for field startDate is 'struct'
When I check the rendered html code, there is a hidden field for startDate with value 'struct' and the correct value is under field 'startDate_value'
<input type="hidden" name="startDate" id="startDate" value="struct">
<input type="text" id="startDate_value" name="startDate_value" readonly="true">
Now in my code I have placed this calender code in a template and its value is being used in javascript at lot of places.
I am using this code while trying to upgrade my Grails application and not writing it from stratch. So updating all the javascript code and appending "_value" involves lot of work.
In older version of my Grails application, calendar was rendered using YUI which now has issues, so I am trying calendar plugin.
Is this (getting 'struct' as the value) an issue with Grails calendar plugin ? Is there any workaround ? Thanks.

don't know if it would of some help for you...
I have a small taglib for a datepicker, which in turn, uses the jquery datepicker and have - of course - also a hidden DateField with a struct value. It needs - beside of that - also fields for day, month and year to work seamlessly with grails.
I use my taglib in some of my projects (grails 2.x.x projects) without changing the grails-logik etc. Works seamlessly.
You need - of course - the jquery + datepicker javascripts in your page...
If it might help, here's the url: jquery-datepicker-taglib
It was once a quick hack, and my first taglib, because of that it might not be as nice coded as you would expect, but since than, it works in a lot of use-cases... :-)
...
I don't know the plugin you mentioned, but in general, the grails 2.x date-field consists of 4 fields:
<input type="hidden" name="reDat" id="reDat" value="date.struct" />
<input type="hidden" name="reDat_day" id="reDat_day" value="" />
<input type="hidden" name="reDat_month" id="reDat_month" value="" />
<input type="hidden" name="reDat_year" id="reDat_year" value="" />
normaly not of type hidden.
But in my case, I have an additional field for the datepicker and populate after changing the date the grails-fields for the date, that the rest of grails can go working without any other/additional action taken...

Related

Using URL parameters for webforms that seem to be resistant to them?

I'm attempting to write a little script that, as part of it, would automatically complete a webform using data from a dictionary.
I've developed this script for other forms in the past with a pretty simple setup: the elements in the form are identified with a line like...
<input type="text" name="full_name" id="full_name_id" maxlength="80" value="">
<input type="text" name="title" id="title_id" maxlength="80" value="">
So, I'd navigate to www.theformsite.com/theform.php?full_name_id=David&title_id=Stuff and find those slots already filled in.
For a couple new forms I've been working with though, that doesn't seem to work: there's no response to these parameters. Are there any general things that could prevent this from working that I should check on?

set textbox value with razor only uses numeric portion

I am setting the value "30 Day Report" to
<input type="text" value=#Model.rpt.ReportDescription.ToString() />
But the value ends up being only "30". I verified this using chrome developer tools. It works if I use #Html.TextBox() or #Html.TextBoxFor() so I know the value comes through, but I don't want to use any html helpers. How can I make the value display properly without html helpers?
Thank you.
You forgot the quotes " around the value:
<input type="text" value="#Model.rpt.ReportDescription.ToString()" />
// ^ ^

Rails-Backbone Model save issue

This page is to edit the account information.
Template file,
<input type="text" id="account_name" class="form-control" placeholder="Enter Name" value="<%=account.name%>"/>
<input type="text" id="account_company_name" class="form-control" placeholder="Enter Company Name" value="<%=account.company_name%>"/>
<a id="account_next_btn" class="btn" role="button">Next</a>
view file,
events:
'click #account_next_btn': "updateAccount"
updateAccount: (e)->
e.preventDefault()
#account.save({"name": #$el.find("#account_name").val(),"company_name": #$el.find("#account_company_name").val()})
ok, this works fine. it sends the updated input form parameters.
the thing i'm curious is, there should be a better way, not setting the updated values manually like my code.
in rails backbone:scaffold it doesn't have this kind of code.
it just
#model.save()
that is all they do.
but in my code, if i just call
#account.save()
it sends the parameter, that not have been updated.
That’s because Backbone by default doesn’t include any kind of data binding library. Data binding lets you keep a model attribute synced with a form field value.
Backbone-Rails includes the simple backbone_datalink.js, which sets up a simple form binding when you create the scaffold.
There are many other binding plugins that work with Backbone, such as Backbone.ModelBinder and Rivets.js.

Rails will_paginate custom renderer manual page number

Hy
What i want to do is to create a custom renderer for will_paginate which renders first, previous, next and last page and a input field where the user can type in the page number manually. I already have the links for first, last etc. but i stuck at the input field. I could create a form in the view but the input field has to be rendered between the previous and next links.
Does anyone know how to do this?
Thanks for your help
You can do this as a separate form (make sure it is a GET). All you
need is the one input element named page. Something as simple as this
should work (not all browsers may like the #). I dropped it into a
site I'm playing with now and it worked. Put it anywhere on your page.
You might have to make something more complicated if you need to
incorporate search terms.
<form action="#" method="get">
Go to page: <input type="text" name="page" value="" size="2"
maxlength="4" />
<input type="submit" name="btnSubmit" />
</form>

Struts2 : Using form action

I am working with a struts2 based application
Inside my JSP page for form submission is it mandatory to use s:form (Predefined struts component )
Because when i tried this way it worked (calling the Action class under struts.xml )
<s:form action="HelloWorld" >
<s:submit />
</s:form>
But When I tried to use normal form submission as shown
<form action="HelloWorld">
<input type="Submit"/>
</form>
It isn't working , it gave me 404 error .
please tell me is it mandatory to use and for data submission ??
A struts form action and an HTML tag form action are different. You can use a standard HTML form tag with struts if you create a struts specific URL for example (off the top of my head):
if using in multiple places, generate the url in and call like this -
<s:url id="myActionUrl" action="HelloWorld" />
<form action="<s:property value="%{myActionUrl}" />">
<input type="Submit"/>
</form>
or using in a single instance -
<form action="<s:url id="myActionUrl" action="HelloWorld" />">
<input type="Submit"/>
</form>
You can often look at the page source in your browser to see what Struts generates and recreate it manually like this. You will often end up using additional struts tags such as property to retrieve values from your value stack, but it is useful at times, for instance when generating JavaScript code dynamically.
No, it's not mandatory to use any of the S2 tags, but as Russell says, you need to duplicate the correct action URL.
You also need to be a little careful when mixing-and-matching S2 form tags with non-S2 HTML form tags, because the default S2 theme adds additional HTML markup to the page; they don't just create form tags--the default theme uses table tags to lay out the form.
You can use s:form for form and
<input type="Submit"/>
can be replaced by
<button type="submit"/>
It's not about which to use,it is what you want from it.Struts2 tags provides additional capabilities to the form.
Please go through below two links to get the diffrence
1] http://struts.apache.org/release/2.1.x/docs/form-tags.html
2] http://www.w3schools.com/tags/tag_form.asp
some facilities such as namespace,tooltip,tooltipIconPath and many are provided by struts2 tags.

Resources