Get value of CollectionOfElements annotation Map

Here is the HQL query to retrieve the value of CollectionOfElements annotation field Map attributes within object ObjectUnderConsideration.

SELECT elements(t.attributes) FROM ObjectUnderConsideration as OurObject INNER JOIN t.attributes as attributeField WHERE CONDITION=’your-condition’

Releasing Web Applications

September 17, 2012 Leave a comment

MS DOS script to close batch file upon execution

MS DOS batch script to restart Internet explorer followed by closing the parent batch file even though the child process has not been closed.

start “” taskkill /im iexplore.exe
start “” “C:\Program Files\Internet Explorer\iexplore.exe” google.com
CLS
EXIT

Categories: Scripting Tags:

Jquery ajax call manipulating DHTML

March 31, 2012 Leave a comment

Code snippet to change Check-box state based on Server side call upon dropdown selection change

HTML

<select name=”dropDown” id=”dropDownId”>
<option>Value1</option>
<option>Value2</option>
<option>Value3</option>
<select>  <!– Intentional typo to preserve HTML code –>

<span id=”changingCheckboxes”>
<label for=”group1″>One</label>
<input type=”radio” name=”group1″ id=”1″ value=”option1″/>
<label for=”group1″>Two</label>
<input type=”radio” name=”group1″ id=”2″ value=”option2″/>
<label for=”group1″>Three</label>
<input type=”radio” name=”group1″ id=”3″ value=”option3″/>
<label for=”group1″>Four</label>
<input type=”radio” name=”group1″ id=”4″ value=”option4″/>
</span>

Jquery

function UpdateCheckBoxStatus () {
var CurrentChoice = $(“#dropDownId”).val();
$.ajax({
url: “/serverSideUrl”,
data: { “selectedDropDownId”: CurrentChoice },
type: “post”,
dataType: “json”,
success: function (data) {
SetCheckbox($(“#changingCheckboxes”).children(“input:[type='radio']“), true);
$.each(data.disabled, function () {
SetCheckbox($(“#changingCheckboxes #” + this), false); });
}
});
}

function SetCheckbox (th, state) {
if (state) th.removeAttr(“disabled”);
else if (!state) th.attr(“disabled”, true);
}

$(‘#dropDownId’).change(UpdateCheckBoxStatus);

Java 

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
String selectedValue = request.getParameter(“dropDownId”);
YourDao yourDao = new YourDao();
Map<String, List<String>> disabledOptions = cycleDao.determineStateDropDown(selectedTool);
String json = new Gson().toJson(disabledOptions);
response.setContentType(“application/json”);
response.setCharacterEncoding(“UTF-8″);
response.getWriter().write(json);
}

Categories: Java, Javascript, Jquery Tags: , , , ,

Factorial without recursion Java

November 13, 2011 Leave a comment

Here is the non-recursive way of calculating Factorial in Java:

public class FactorialUtility
{
public static BigInteger factorial(int n)
{
BigInteger ret = BigInteger.ONE;
for (int i = 1; i <= n; ++i) ret = ret.multiply(BigInteger.valueOf(i));
return ret;
}
}

Agile Practices Reference Space

  • Continuous Integration
    Martin Fowler@ThoughtWorks
  • Test Driven Development
  • Pair Programming
  • Collective Code Ownership
  • Categories: Extreme Programming, Java, TDD

    Reference Space

    Some of the useful spaces for reference:

    Categories: Usability, Web Design Tags:
    Follow

    Get every new post delivered to your Inbox.