-J-Dfile.encoding=UTF-8
Alex Ai's Notebook
2014-11-30
NetBeans控制台中文显示乱码的解决方案
在NetBeans的配置文件(/etc/netbeans.conf)中找到netbeans_default_options, 并在参数末尾添加上:
2013-11-27
Firefox, don't fill the form element from cache automatically
Firefox is smart. it can remember the value of your form element and refill it back after you refresh the page. but sometimes you control the form element by code and Firefox will fill the value back to a wrong element. For Example: you have a list of check boxes with first one checked. then Firefox will remember the first one is checked. if you delete the first one by code and refresh the page. Firefox will set the second one (now is first one) checked that is not what you want. how to disable the Firefox cache behavior for specific form element? just set attribute autocomplete="off" for the form element.
2013-11-12
Hack TPanel to use VCL and Firemonkey together
Put a panel on VCL form, then assign the form property to Firemonkey Form object.
Here is the code to hack TPanel:
Here is the code to hack TPanel:
unit FMXAdapter; interface uses FMX.Forms, Vcl.ExtCtrls; type TPanel = class(Vcl.ExtCtrls.TPanel) private FForm: TCommonCustomForm; procedure ResizeForm; procedure SetForm(const AForm: TCommonCustomForm); protected procedure Resize; override; public property Form: TCommonCustomForm read FForm write SetForm; end; implementation uses Types, Winapi.Windows, System.SysUtils, FMX.Platform.Win; { TPanel } procedure TPanel.Resize; begin inherited; ResizeForm(); end; procedure TPanel.ResizeForm; begin if Assigned(FForm) then begin FForm.SetBounds(BorderWidth, BorderWidth, ClientWidth + BorderWidth, ClientHeight + BorderWidth); end; end; procedure TPanel.SetForm(const AForm: TCommonCustomForm); begin FForm := AForm; FForm.BorderIcons := []; FForm.BorderStyle := TFmxFormBorderStyle.bsNone; ResizeForm(); FForm.Visible := True; Winapi.Windows.SetParent(FmxHandleToHWND(FForm.Handle), Handle); end; end.
2013-11-06
Add Jar file as library in Android Studio
add in build.gradle:
add multiple files like this:
then rebuild the project.
compile files('libs/android-query-full.0.26.2-beta.jar')
add multiple files like this:
compile fileTree(dir: 'libs', include: '*.jar')
then rebuild the project.
2013-11-05
Android Ajax Authentication using Android-Query and Grails Spring Security Plugin
This post shows code on client end only.
Code in fragment class:
Login:
Logout:
Do something need to run with or whithout authentication:
Code in fragment class:
private AQuery aq; String svalue = null; // keep current session id @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); aq = new AQuery(getActivity(), rootView); aq.id(R.id.loginbutton).clicked(this, "onLoginButtonClick"); aq.id(R.id.logoutbutton).clicked(this, "onLogoutButtonClick"); aq.id(R.id.dobutton).clicked(this, "onDoButtonClick"); return rootView; }
Login:
public void onLoginButtonClick(View view) { String url = "http://10.0.3.2:8090/GrailsTest1/j_spring_security_check"; Map<string object=""> params = new HashMap<string object="">(); params.put("j_username", "admin"); params.put("j_password", "admin"); params.put("ajax", "true"); cb = new AjaxCallback<jsonobject>(); cb.url(url).type(JSONObject.class).params(params).weakHandler(this, "loginCallback"); cb.header("Content-Type", "application/x-www-form-urlencoded"); aq.ajax(cb); } public void loginCallback(String url, JSONObject json, AjaxStatus status) throws JSONException { if(json != null) { List<cookie> cookieList = new ArrayList<cookie>(); cookieList = status.getCookies(); for (Cookie cookie : cookieList) { if(cookie.getName().equals("JSESSIONID")) { svalue = cookie.getValue(); } else { svalue = null; } // do something when succeed to log in } else { // do something when fail to log in } }
Logout:
public void onButton3Click(View view) { String url = "http://10.0.3.2:8090/GrailsTest1/logout/index?ajax=true"; Map<string object=""> params = new HashMap<string object="">(); AjaxCallback<string> cb = new AjaxCallback<string>(); if(svalue != null) cb.cookie("JSESSIONID", svalue); cb.url(url).type(JSONObject.class).params(params).weakHandler(this, "logoutCallback"); aq.ajax(cb); } public void logoutCallback(String url, String json, AjaxStatus status) throws JSONException { if(json != null){ // do something when succeed to log out }else{ // do something when fail to log out } }
Do something need to run with or whithout authentication:
public void onDoButtonClick(View view) { String url = "http://10.0.3.2:8090/GrailsTest1/main/doAction?ajax=true"; AjaxCallback<string> cb = new AjaxCallback<string>(); cb.url(url).type(JSONObject.class).weakHandler(this, "jsonCallback"); if(svalue != null) cb.cookie("JSESSIONID", svalue); aq.ajax(cb); } public void jsonCallback(String url, JSONObject json, AjaxStatus status) throws JSONException { if(json != null){ // do something when succeed to get data from server }else{ // do something when fail to get data from server } }
2013-11-03
Visit local PC web server from Android application in Genymotion
The URL address used by Android applicaiton in Genymotion should be set to 10.0.3.2, not localhost. For example:
http://10.0.3.2:8090/GrailsTest1/main/index
http://10.0.3.2:8090/GrailsTest1/main/index
How to add Syntax Highlighting to Blogger Engine
CraftyFella has a good post for it, please go to:
http://www.craftyfella.com/2010/01/syntax-highlighting-with-blogger-engine.html
http://www.craftyfella.com/2010/01/syntax-highlighting-with-blogger-engine.html
Subscribe to:
Posts (Atom)