This week's book giveaway is in the Cloud forum.
We're giving away four copies of Terraform in Action and have Scott Winkler on-line!
See this thread for details.
Win a copy of Terraform in Action this week in the Cloud forum!

V. Keating

Greenhorn
+ Follow
since May 14, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
4
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by V. Keating

Thank you for your response.
The way you explain that made it much easier to understand than the explanation on the Kotlin site.
I will add that to my tool bag for later and see what other questions may be of use to others reading up on Kotlin.

Thank you again!
2 years ago
Hi there,

I am totally new to Kotlin and researching the right book to use for teaching myself.
I love other Head First publications on programming topics due to the format.

I was reading online about special features that Kotlin has that Java does not.
I cam across Extension Functions.
The examples given on the https://kotlinlang.org/docs/reference/extensions.html site are functions like sort.
Paraphrasing: The argument is that this extension function allows you to extend the class without having to inherit from the class.
I was wondering if you could elaborate on the benefits of using this new functionality in Kotlin and why this feature is beneficial?
How would you use this functionality in a real world situation?
2 years ago
Hi there Dawn & David Griffiths,

Thank you for writing a Head First book on Kotlin.
Welcome to the Ranch. Hopefully we can challenge you with some good questions on Kotlin.
2 years ago
Thank you for answer.

I have read over the additional post you mentioned.
I did not realize that Kotlin could be transpiled to other native bytecode.
It sounds like Kotlin has a lot of very useful features to contribute to the modern developers needs.
Especially considering the note that it can be used to compile native bytecode to run on embedded systems and iOS.

I really appreciate you taking the time to answer.
I am learning so much just from reading all the posts.
2 years ago
I am new to Kotlin and recently found a few positions during a job search that listed Kotlin as a skill they would prefer.
I have purchased a coding course from udemy to dig into the language and expand my knowledge but I have a few questions about the language it's self.

Is Kotlin Platform Independent like Java?
If not are there plans to develop it further to become platform independant?

What are the best ways in your opinion, to get familiar with the language when you are not using it in a work type setting?

Thank you!
2 years ago
Thank you for all your help. I think I can figure out how to move forward from here.
9 years ago
JSP
I believe we are currently using AJAX dojo.xhrPost as the mean of sending data to the server for the comments. I have attached my JavaScript function. I have included the form where the JavaScript function is called as well. Would I need to change this to use the servlet? or is there another way that is better suited for this layout? I just want to make sure I am taking the most efficient path. Thank you for your responses so far.


function addComment(form)
{
//add to the database before displaying...
var comment = form.elements.namedItem("itemComment").value;
if (comment == null || comment == "")
{
createDojoAlert("Add Comment","<li>Comment required</li>");
}
else
{
var commentType = form.elements.namedItem("commentType").value;
var itemID = "<s:property value="itemID" />";
var itemRowNum = "<s:property value="itemRowNum" />";

dojo.xhrPost
({
url: "<s:url action="AddComment" namespace="/ImageTyper" includeParams="none"/>",
handleAs: "json", //return type (text, xml, json, etc...)
timeout: 10000, //Time in milliseconds (10 secs)
content: {"itemID" : itemID, "itemRowNum" : itemRowNum, "comment" : comment, "commentType" : commentType},
load: function(data, evt)
{
try
{
if (!data.success)
{
createDojoAlert("Add Comment","<li>Error: " + data.error + "</li>");
return;
}
}
catch (Exception)
{
createDojoAlert("Add Comment (catch block)","<li>Error: " + Exception + "</li>");
}
},
error: function(error)
{
createDojoAlert("Add Comment (dojo error)","<li>Error: " + error.reason + "</li>");
}
});

var tr = document.createElement("tr");
tr.align="left";
tr.className="odd";

var td = document.createElement("td");
td.style.borderBottom="1px solid #000000";
td.style.verticalAlign="top";
td.style.fontSize="11px";

var span = document.createElement("span");
span.style.textDecoration="underline";
span.appendChild(document.createTextNode("<s:date name="#request.now" format="MM-dd-yyyy"/>"));
td.appendChild(span);

td.appendChild(document.createElement("br"));

td.appendChild(document.createTextNode("<s:property value="#session.this_user.loginName"/>"));

tr.appendChild(td);

td = document.createElement("td");
td.style.borderBottom="1px solid #000000";
td.style.verticalAlign="top";
td.style.fontSize="11px";
td.appendChild(document.createTextNode(comment));

tr.appendChild(td);

/* Do some magic to find the correct row to add this comment */
var tbody = dojo.byId("commentsTbl").tBodies.item(0);
var trIdx=0;
var trCnt=0;
for (var i=0; i<tbody.childNodes.length; i++)
{
if (tbody.childNodes.item(i).tagName == "TR")
{
trCnt++;
}
if (trCnt == 2)
{
trIdx=i;
}
}

tbody.insertBefore(tr, tbody.childNodes.item(trIdx));

toggleDisplay(dojo.byId('addCommentDiv'));
toggleButtonValue();
form.elements.namedItem("itemComment").value = "";
}
}




<form name="addCommentForm" style="padding:0px; margin:0px;">
<table>
<tbody>
<tr>
<td>
<input type="hidden" name="commentType" value="UserComment" />
<textarea rows="3" cols="70" name="itemComment"></textarea>
</td>
</tr>
<tr>
<td>
<hr />
<input type="button" class="button" onclick="addComment(this.form); return false;" name="SaveComment" value="Save Comment" />
</td>
</tr>
</tbody>
</table>
</form>

9 years ago
JSP
Hello,

I am attempting to program an auto-email feature into a JSP page.
The user logs into to an application where they type information from an image.
When there is a problem with the image they click the "comment" button which takes them to a popup,
where they can comment about the image problems(separate JSP file).
I want to add a feature in the popup that allows them the option to send an e-mail with the comment as the body.
I have seen examples of how to set up an e-mail form but I want the feature to auto send the e-mail and eliminate the human error.
I can look up the username and user address for the FROM: and I can look up the appropriate e-mail for the TO:.
Since I will already have the body of the message in the popup "comment" form I would like to know if it is possible to
program the app to send an e-mail automatically when the comment is submitted.
If, for instance, a check box "send email" is checked, then I would like the application to submit the comment to the db as usual and then send the e-mail before returning to the original application.
I am not looking for specific code just guidelines to help me build this. Any help would be appreciated.

Thank you in advance.
9 years ago
JSP
I am fairly new at this.
I had to go in to some existing code and make a change.
I believe that this block here is making the change that I need.
However, I don't think that it is executing.
It looks to me like these struts are not working. I am not familiar with the syntax.
I cannot see the problem from what I am looking up on line.
I have checked for missing brackets, semicolons, commas, <>, I need a fresh pair of eyes.
Thank you in advance.

Eclipse error is "Syntax error on token(s), misplaced construct(s)"

Pseudocode for other blocks------------------------------------------------------
Function saveAddress
if (Validate address Form)
dojo.xhrPost({
try {
if (data && data.PR && data.PR.PRID > 0) {
var newAddress="";
var newAddressToolTip="";

// keep local address vars up to date block of
_x.y=dojo.byId("PR.xyz").value.toUpperCase();
_x.y=dojo.byId("PR.xoxo").options[dojo.byId("PR.xoxo").selectedIndex].value;

// build new address block for side panel
//declare variables
//if variable is empty newAddressToolTip += _variable

--------------------------------------------------------------------------------------------------------------------
//Here is where I run into the issues.
<s:if test="Work.order.Num != null">
tooltip+="<br /><b>Parcel: </b><s:PR value="Work.order.Num"/>";
</s:if>
<s:elseif test="Work.PR.lots != null && Work.PR.lots.size > 0">
tooltip+="<br /><b>lots associated with PR:</b><br />";
<s:iterator value="Work.PR.lots" id="parcel">
tooltip+="<s:PR value="Num"/>, ";
</s:iterator>
</s:elseif>

tooltip+="<hr /><b>Submitted Address:</b><br /><app:webFormat value="${requestScope.Work.order.submittedPR.formattedAddress}"/>";
tooltip+="<br /><b>County: </b><s:PR value="Work.order.submittedPR.county.simpleName"/>";

<s:if test="Work.order.submittedPR.subdivision != null">
tooltip+="<br /><b>Subdivision </b><s:PR value="Work.order.submittedPR.subdivision"/>";
</s:if>
<s:if test="Work.order.submittedPR.lot != null">
tooltip+="<br /><b>Lot: </b><s:PR value="Work.order.submittedPR.lot"/>";
</s:if>
<s:if test="Work.order.Num != null">
tooltip+="<br /><b>Parcel: </b><s:PR value="Work.order.Num"/>";
</s:if>
<s:elseif test="Work.order.submittedPR.lots != null && Work.order.submittedPR.lots.size > 0">
tooltip+="<br /><b>lots associated with PR:</b><br />";
<s:iterator value="Work.order.submittedPR.lots" id="parcel">
tooltip+="<s:PR value="Num"/>, ";
</s:iterator>
</s:elseif>
9 years ago