Thursday 3 October 2013

Getting client host or other related info in Play

Getting client host or other related info in Play

Can anyone tell me how to get the client host (the IP address) in or any
other this kind of data in Play Framework (2.1.x)?

Wednesday 2 October 2013

Excel VBA ODBC connection failed

Excel VBA ODBC connection failed

I'm using Excel 2010 VBA to retrieve data from MS Access 2010 with ODBC
connection to SQL Server R2 Express, in my previous machine there is no
issue (32bit platform) but when I got new machine it's always said "ODBC
connection to (odbc name) failed -2147467259".
From Access 2010 to SQL there is no issue, but when I retrieve data from
Excel always trigger this error.
I have check the permission for the user (DBO), all the app in the same
machine, all the services are on, ODBC setting is correct. During the
execution of the script all OK except when the line is opening the table.
Function RetrieveProjectList()
Dim strConn As String
Dim conn As New ADODB.Connection
Dim rec As New ADODB.Recordset
Dim intColCount As Integer
Dim strName As String
Dim strSQL As String
On Error GoTo Error_Trap
strName = ThisWorkbook.path & "\DBSource V0.1.accdb"
Set conn = New ADODB.Connection
strConn = "Provider=microsoft.ACE.oledb.12.0;"
strConn = strConn & "Data Source=" & strName & ";"
conn.Open ConnectionString:=strConn
Set rec = New ADODB.Recordset
strSQL = "SELECT qryProjectList.* " & _
"FROM qryProjectList ORDER BY tblArea.AreaName,tblProject.ProjectName;"
rec.Open strSQL, conn, adOpenDynamic, adLockOptimistic
'Retrieve data from Access
rec.MoveFirst
If rec.Fields.count <> 0 Then
After syntax "rec.open ...." the error pop up. In other machince are OK.
Question:
Is this related to OS version 64bit? What did I miss out here? Any advice
will be highly appreciated.
Thanks, seageath

For each loop returns blank

For each loop returns blank

I have a for each loop in the final step of my asp:Wizard that is supposed
to list all of the text in each textbox that is not null. The textboxes
are in the second step of the asp:Wizard and they are placed in asp:Panel
controls that are made visible or not visible with the use of checkboxes
on the same step. Here is the event with the loop:
protected void Wizard1_FinishButtonClick(object sender,
WizardNavigationEventArgs e)
{
var requested = this.Controls.OfType<TextBox>()
.Where(txt => !string.IsNullOrWhiteSpace(txt.Text));
var sb = new StringBuilder();
foreach (var textBox in requested)
{
sb.Append(textBox.Text); //Add the text not the textbox
sb.Append("</br>"); //Add a line break to make it look pretty
}
Label1.Text = sb.ToString();
}
If I run the application with the loop my label will return blank, no
matter what I fill out. The label is currently in the 3rd step
<asp:WizardStep ID="WizardStep3" runat="server" AllowReturn="false"
Title="Step 3" StepType="Complete">
<asp:Label ID="Label1" runat="server" Text="This text will display
when I run the application without the foreach loop"></asp:Label>
</asp:WizardStep>

How do I make POST request in FRAME

How do I make POST request in FRAME

I've following piece of code
<html>
<head>
<script language="JavaScript">
function redirect() {
window.moveBy(0, 0);
self.focus();
}
</script>
<title>POST request</title>
</HEAD>
<%
String unsaferequest =
request.getQueryString()+"&id="+System.currentTimeMillis()+session.getId();
String saferequest = ESAPI.encoder().encodeForHTMLAttribute(
unsaferequest );
%>
<frameset name="frameset" frameborder="no" cols="*,230px,30px"
onload='javascript:redirect()'>
<frame name="statement" scrolling="auto" src='/test/jsp/download_msg.jsp?
<%=saferequest%>'>
<frameset name="frameset" frameborder="no" rows="20px,*">
<frame name="" scrolling="no" src="/test/html/blank.html">
<frame name="enclosure" style="" scrolling="no"
src='/test/DownloadDisclaimer?
<%=saferequest%>'>
</frameset>
<frame name="hide" scrolling="auto" src="/test/html/hidingFrame.html">
</frameset>
</html>
Now I've to change the src in frame to make it a post request. I found
there is no straight forward way to do this. Could you please give some
sample code to do this?

#EANF#

#EANF#

I have this custom adapter for my listview that is getting filled with a
ArrayList of a custom rowItem class where I put data in.
rowItem.getImage() will return this byte array: I have put the long string
under this in a byte[] variable with getBytes()
R0lGODlhZAAvAPcAAAAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZgArmQArzAAr/wBVAABVMwBVZgBVmQBVzABV/wCAAACAMwCAZgCAmQCAzACA/wCqAACqMwCqZgCqmQCqzACq/wDVAADVMwDVZgDVmQDVzADV/wD/AAD/MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMrADMrMzMrZjMrmTMrzDMr/zNVADNVMzNVZjNVmTNVzDNV/zOAADOAMzO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uNRBcj/UQ3Q8HTsrxSHcX0JFiDQqtvRESRpihNQE85WkHwBFWVdAlhjg4P3a5El+6g+biBiczRsmM9vj7ar572TG4sEiS+EkZpnq0Nqv6SEOrmCEHXcxfWQFtju1imJm8cEdaCmmrBjNY0rcVNofWq1JqNdkw0W3VPRVKVz7xLYKiDCdUgU5AIr3pLuMbzmQTIEuHAZT8IfNhqsqLCx+yIQ5Me2ZXS1i3yiqcgAQEAOwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
Now I have this code:
byte[] imageData = rowItem.getImage();
Drawable logoDrawable = null;
if (imageData != null) {
Bitmap logoBitmap = BitmapFactory.decodeByteArray(imageData, 0,
imageData.length);
logoDrawable = new BitmapDrawable(context.getResources(),
logoBitmap);
}
holder.imageView.setImageDrawable(logoDrawable);
But it won't display a image, if I set a image out of my drawable map it
will show so it reconizes the imageview.

Tuesday 1 October 2013

Highcharts multi line graphs

Highcharts multi line graphs

This is my fiddle
http://jsfiddle.net/a4UQf/
Code:
$(function () {
$('#container').highcharts({
title: {
text: 'Monthly Average Temperature',
x: -20 //center
},
subtitle: {
text: 'Source: WorldClimate.com',
x: -20
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
title: {
text: 'Temperature (°C)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: '°C'
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
series: [{
name: 'Tokyo',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3,
18.3, 13.9, 9.6]
}, {
name: 'New York',
data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1,
14.1, 8.6, 2.5]
}, {
name: 'Berlin',
data: [-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0,
3.9, 1.0]
}, {
name: 'London',
data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3,
6.6, 4.8]
}]
});
});
Here I want to implement in php mysql. Some suggestions would be grateful.
Before that the lines showing there, there must be a check then the graph
should show, for example if i click on tokyo checkbox then tokyo line
graph should show and so on, this should be used in an array, how to do
that please help.

How can i make my square button and spinner the same height?

How can i make my square button and spinner the same height?

usecase:
I want a spinner with a clickable, squared image-button to the right of
it, on the same row, with the button the same height as the spinner.
There was first a problem getting an imagebutton to be square, which i
solved reading this thread: How do I keep the aspect ratio on image
buttons in android?
I now have them on the same row and with the icon square and resized, but
not quite to the size of the spinner, the 9-patch (i think) of the spinner
creates some sort of padding around it and my image uses that to set its
height, so that it looks like this:
If someone can help me out here it would be greatly appreciated.
Layout-xml below:
<LinearLayout android:layout_weight="1" android:id="@+id/spinnerRow"
android:orientation="horizontal"
style="@style/horizontalLayout" android:gravity="top"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:paddingTop="5dp">
<LinearLayout android:id="@+id/spinLayout"
style="@style/spinLayout" android:layout_weight="1">
<Spinner android:id="@+id/locSelect"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:prompt="@string/loc_prompt"></Spinner>
</LinearLayout>
<com.karpet.nuba.util.SquareButton
android:id="@+id/info" android:orientation="horizontal"
android:gravity="top" android:layout_height="fill_parent"
android:layout_width="wrap_content" android:layout_weight="0.5">
<ImageView
android:id="@+id/info"
android:src="@drawable/info"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</com.karpet.nuba.util.SquareButton>
</LinearLayout>