Dynamic Extjs DateFields in the dynamic form - java

I am very much thankful to this stackoverflow,as i am getting required help very quickly here.
I am facing a problem in ExtJs.(with java spring backend combination). I am having a jsp file like this.
<c:when test="${eformDetails.controlType=='date'}">
<span id="eform_date_${eformDetails.id}"></span>
</c:when>
And in the js file i am trying to create date objects like this.But not working :-(
$.each('span[id^=["eform_date_"]',function(){new Ext.form.DateField({renderTo:this.id,name: 'form_0',id :'date_'+this.id,width: 140});});
My Requirement is if the eformDetails.controlType is date then i have to display a date field there.
Could please help me in this.
I am very much thankful to you guys..
Thanks in advance
-Sathya

The selector you're looking for is probably:
$.each('span[id^=eform_date_]', function() { /* DateField */ });
The unmatched bracket is a syntax error. You can test it in your browser's console to make sure you're getting it right.

Related

Jsoup: get the html nearest tag before a tag

I go a tag name <div id= "d1">. But I want to know the tag, which is before this tag( the older bro/sis of this tag .anyone have an idea?
I am using java.
OP found an answer:
I think i got my own answer. It's lastElementSibling(). I read it in this Jsoup API I hope this will help anyone like me now.

Filling out a HTML-form with complex name (dot-notation in input-tag) with Java and Jaunt API

-
hey folks,
i am building a Java-tool, trying to automatically fill out some form input elements in an HTML-Page using Java and Jaunt API.
the HTML-Code is like:
<fieldset class = "fieldsetlong">
<legend>searchprofile</legend>
<label for="reference">reference:</label>
<input maxlength="50" name="reference" id="reference" type="text" />
</fieldset>
<fieldset class = "fieldsetlong">
<legend>searchcriteria</legend>
<label for="surname">surname:</label>
<input name="searchprofile.surname" id="surname" type="text" />
</fieldset>
The Java-Code for filling in the "normal" Input-field reference (it works) looks like:
form.set("reference", "123Test");
Unfortunately, I am not able to fill out the fields that use the dot-notation searchprofile.surname in the name
Here's a sample of what i've tried (without success):
form.set("surname", "TestPerson");
form.set("searchprofile.surname", "TestPerson");
form.set("name=\"searchprofile.surname\"", pers.getSurname());
form.set("id=\"surname\"", pers.getSurname());
For each of these commands I get a NotFoundException and don't know whether I can do this with Jaunt.
It would appreciate any kind of help in this regard.
Thanks in advance
Edit - is there a way to reach the dot-notated input-field searchprofile.surname with JSoup?
HTML allows dots in the name-Attribute, but does Jaunt accept this abc.name?
Not sure about Jaunt, never used it before. However Jsoup seems to be a pretty decent library to be used here. I myself have been using Jsoup for a fairly long time and it has been very successful in scraping web pages, filling input form and submit, and of course, HTML parsing!
I've posted a step by step guide to fill in form input fields and submit to server in the following answer: How to login with Jsoup
Basically it works very similar to your code, a very brief example would be:
Connection.Response response = Jsoup.connect(url)
.data("Name", "Value")
.method(Method.POST).execute();
Today, at work the Jaunt solution with
form.set("searchprofile.surname", "TestPerson");
worked like a charm.
I don't know what the problem was earlier but I am glad that it worked.
The HTML allows to use dots and minus, etc. which I misinterpreted as some kind of nested forms or hierarchies but the dot-notation is just a valid name-attribute in HTML.

Issue regarding JSP Forward

In my code I am trying to forward my request by using below line
<jsp:forward page = "<%=request.getContextPath()%>/Welcome.do"/>
However its giving error below
org.apache.jasper.JasperException: /obajsp/OBAHeader.jsp(3,27) JBWEB004214: Error unquoting attribute value
Please someone help me to understand what is issue in my written code?
EDIT:
this was currently working in production without any issue and giving issue in my local IDE
Have you tried using the expression language, rather than a scriptlet?
<jsp:forward page = "${pageContext.request.contextPath}/Welcome.do"/>
<jsp:forward page = "${pageContext.request.contextPath}/Welcome.do"/>
you dont need inline java to get the context path. expressionlanguage is much more comfortable.

Refeshring JSP page in Javascript

I am trying to refresh the JSP page after certain operations, I am using DWR to be able to use my classes in Javascripts in the JSP files so I have this code:
function removeDN(numplanindex){
DBOps.removeDN(numplanindex);
relaod(true);
}
the above code will break the removeDN() and it would not refresh the page, I have also tried window.location.reload(true) and document.location.reload(true).
I am not sure about the difference as I barely know any Javascript but according to everything on google this should work. I am wondering if anybody know what is wrong with what I am doing wrong.
Thanks
It should be reload(true) instead of relaod(true)
Also see http://www.w3schools.com/jsref/met_loc_reload.asp

struts2 jquery from date and to date

I am working a webproject using struts2 and I used struts2 jquery plugin for datepicker.
Now I need to validate ToDate depending on FromDate.
ToDate shouldnot be greater than FromDate
validation should be like this, datepicker should disable the behind dates accodring to fromdate.Then user not able to select lower than the from date
Please let me know how can I implemt this.
Please post the code will help
Thanks in advance
That's your choice how you want to impliment the validation.There are 2 ways which as of now seems feasible to me
Client side validation using JavaScript.
Server Side validation in your action class.
For the first part your both data-picker must have id and name so once user filled ToDate and FromDate and before submitting the form you can call a java-script function where you can fetch the values of respective date-picker fields using java-script document.getEmelemntById() and can run your comparison logic.
Other option is to let Struts2 fill the ToDate and FromDate values in your action class and you can use validate method inside your Action to perform date validation.choice is all yours.
You can even play around with validation framework even.
Update
After playing around with J query plugin source code here is the workaround we have
<s:form id="form" theme="xhtml">
<sj:datepicker id="date12" name="date12" label="With Close Event" onCompleteTopics="onDpClose"/>
<sj:datepicker id="date13" name="date13" label="With Min and Max Date" minDate="0" maxDate="+2m"/>
</s:form>
<script type="text/javascript">
$.subscribe('onDpClose', function(event,data) {
$('#date13').datepicker( "option" , 'minDate',event.originalEvent.dateText );
});
</script>
In similar way can work for other way around.Hope this will work for you.
There is an example similar to what you ask for on datepicker demos site.
I've modified and tried to simplify that example and created a fiddle for it which you can find here: http://jsfiddle.net/melih/vRULq/

Categories

Resources