Posts

java - Jersey filter ContainerRequestContext with HttpServletRequest return nullpointer -

i injecting httpservletrequest containerrequestfilter . when trying use abort , getting nullppointerexception . @provider public class authorizationrequestfilter implements containerrequestfilter { @context httpservletrequest httprequest; @override public void filter(containerrequestcontext requestcontext ) throws ioexception { // string auth = requestcontext.getheaderstring("authorization"); uriinfo uriinfo = requestcontext.geturiinfo(); system.out.println(uriinfo.getpath()); //login request if (uriinfo.getpath().equals("resource/users/login")) { return ; } if (httprequest.isrequestedsessionidvalid()== true) { requestcontext.abortwith(response .status(response.status.unauthorized) .build()); } stacktrace :09:28 pm org.apache.catalina.core.standardwrappervalve invoke severe...

c# - Variable declaration differences var with cast or -

this question has answer here: initializing 'var' null 2 answers is there background difference between 2 declarations: var x = (string)null; and string x = null; will runtime treat declarations different ways? compiler produce same il? yes, produces same il: void main() { var x = (string)null; string y = null; } produces (with optimizations turned off): il_0000: nop il_0001: ldnull il_0002: stloc.0 // x il_0003: ldnull il_0004: stloc.1 // y il_0005: ret from compilers perspective, assigning null string variable.

android - Replace Action bar with toolbar -

i'm using toolbar replace actionbar. going before replacing. after replacing gives me error: java.lang.runtimeexception: unable start activity componentinfo{com.oi.mmg/com.oi.mmg.eventdetailsscreenactivity}: java.lang.illegalstateexception: this activity has action bar supplied window decor. not request window.feature_action_bar , set windowactionbar false in theme use toolbar instead. without knowing code suggest using parent theme application: theme.appcompat.light.noactionbar the property "windowactionbar" "false" default. and if using appcompat activities should extend "appcompatactivity".

mysql - Rails 4 access table attributes from has_one association -

i have 2 models user , account class user < activerecord::base has_one :account end class account < activerecord::base belongs_to :user end in users controller retrieving users @user = user.list('', false,'company', 'asc') where "list" method described in model retrieve records in users table have 2 columns "id" , "company_name" , in account table have columns "user_id" , "country" now want array @user retrieve company name , country can found user_id in accounts table please tell me how can thankx in advance how about: # app/models/user.rb class user < activerecord::base has_one :account scope :with_account_info, -> { includes(:account) } default_scope{with_account_info} end the final 2 lines merged 1 if prefer that, i.e.: default_scope{ includes(:account) } hth

android - java.lang.NoClassDefFoundError: Exception for Loading Tabs in an Activity -

Image
i try implement activity contains tab views, when want run project, got following exception: java.lang.noclassdeffounderror: com.example.activities.tabbaractivity$sectionspageradapter e/androidruntime(5072): @ com.example.activities.tabbaracitivity.loadmaintabs(tabbaracitivity.java:129) e/androidruntime(5072): @ com.example.activities.tabbaracitivity.access$1(tabbaracitivity.java:122) e/androidruntime(5072): @ com.example.activities.tabbaracitivity$servicemessagehandler.handlemessage(tabbaracitivity.java:370) e/androidruntime(5072): @ android.os.handler.dispatchmessage(handler.java:102) e/androidruntime(5072): @ android.os.looper.loop(looper.java:149) e/androidruntime(5072): @ android.app.activitythread.main(activitythread.java:5061) e/androidruntime(5072): @ java.lang.reflect.method.invokenative(native method) e/androidruntime(5072): @ java.lang.reflect.method.invoke(method.java:515) e/androidruntime(5072): @ com.android.internal....

android - Spinner background too big -

our graphic designer sent me png put inside spinners of our app. but, image appears big in phone. resize it, due different screen sizes, don't think nice solution. i did spinner_selector.xml: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/icono_desplegable_activar" android:state_enabled="true"/> <item android:drawable="@drawable/icono_desplegable" android:state_enabled="false" android:state_window_focused="false"/> </selector> and, then, in layout: <spinner android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/textactivity" android:layout_alignparentstart="true" android:id="@+id/spinneractivity" android:background="@drawable/spinner_selector"/> how can te...

c# - How to create a scaling and size-changing Per-Monitor DPI-aware application that is backwards compatable with Windows 7? -

i'm new wpf (and dpi-awareness apis) , writing application running in windows 7, 8.1, , 10. use multiple monitors different per-monitor dpi settings, , interested in making application compatible possible across desktop configurations. i know possible add manifest wpf application, uncomment section dpi awareness, , set true/pm . allows program per-monitor dpi-aware in windows 8.1 , 10 (thus looking clean , sharp on various monitors), run system-aware in windows 7. but can 1 step better? microsoft provides neat tutorial here shows how create per-monitor dpi-aware wpf application. create new object in c++ replace <window> uses windows 8.1 apis not detect dpi change between monitors, re-size application @ runtime, matching change in dpi. end result not app per-dpi aware , sharp looking, when switching between large , small monitors of various sizes, app looks user change same physical size (in inches or centimeters) on screen. the downside microsoft's win32 code...