w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Yii: Get value from column of a MANY_TO_MANY connectiontable into another table on the model layer
I think your relations have some problems. You say that City - Product is Many to Many yet your relation city in the Products model is a HAS_ONE instead of a HAS_MANY. and the other issue with your relations is that you are trying to use a statistical query to get a scalar value from CityHasProducts, but statistical queries are for retrieving aggregate values like COUNT(*) or SUM(amount). Since City to product is Many to Many, there is no single City for a given Product, you can however get an array of cities for a given product. that array may only have one city in it, but it will be an array none the less. you can retrieve the amount for a product given a city and product, and you can get at it from either the product or the city, your choice. Try this: $product = Product::model()

Categories : PHP

N-Tier Service Layer Validation Show Business Logic Error in Presentation Layer
First, your overall approach to MVC looks good to me :-) Second, you most likely want to use DataAnnotation on your view models for model validation. Have a look this blog post for a good intro on using it in ASP.MVC. In case of custom validation not suitable for data annotation you can do the following in your controller: try { // the following exception could be thown by some nested validation logic // e.g. while processing a post request throw new ValidationException("the error description"); } catch (ValidationException exception) { ModelState.AddModelError("", exception.Message); }

Categories : Asp Net Mvc

After switching Views, I want my label text to remain what it was before switching
Put the same code in "viewDidAppear" as well. viewDidLoad is called only once when the view is created, not every time it appears. In viewDidLoad, make sure to call [super viewDidLoad]; in be beginning. Do the similar in viewDidAppear.

Categories : Misc

Annotating over an NSImageView with CALayers, layer-hosting or layer-backed?
The solution I went for was to not alter the NSImageView subclass's layer at all. Instead I added a subview to the NSImageView subclass, constrained the view such that is has the same bounds as the parent, and then made this subview layer-hosting. It is then possible to add sublayer to this 'annotation' view's layer. In this way I can annotate on top of an NSImageView.

Categories : Xcode

Which pattern to implement on Data access layer and on the business layer?
Build a Service Layer that the Presentation Layer (web app) references. Then in the Service Layer you have a reference to the BLL, EF5 Entities and DAL. The Service Layer can be just a Class Library (ASP.NET Web API for example) or a Web Services layer (WCF for example). Now your web application has no hard reference to the DAL, but rather only knows of the Service Layer and the EF5 Entities.

Categories : Asp Net

What's the difference between link-layer and e.g. transport-layer reliability?
Link layer reliability provides reliable delivery over a link. However, packet can still be dropped in router for a limited buffer size. Therefore, even all links provide reliable service, it doesn't guarantee an end-to-end reliability.

Categories : Networking

Switch from Terrain layer to Satellite layer using Mapbox
With MapBox there is no concept of "modes", just different maps each with their own Map ID. So create a map at http://tiles.mapbox.com/newmap based on terrain, then another based on satellite imagery. Switch between them with the second argument to L.mapbox.map (see http://www.mapbox.com/mapbox.js/api/v1.0.4/#L.mapbox.map) using their respective IDs.

Categories : Javascript

Application layer references data layer directly
If you have a valid reason for calling the data layer directly, then do it. If you add a pass-through function in the business layer, then all you've done is added more code for no apparent benefit. Now, if your business layer is exposed via an interface, IBusinessLayer for example, then adding a ProcessAllPersons() function to it and having it pass the call directly to the data layer makes more sense and consistency. This is what I would recommend.

Categories : Vb.Net

How to update a layer property for UIView and keep the layer for it subview?
The problem isn't all of your changes to the layer, its just the shadow. That's because the shadow is applied to the layers composited alpha channel, and that includes its sub layers. You could either: Use a shadow path instead of the standard offset Add a different sub layer on which to specify the shadow (where it is a sibling to the button)

Categories : Iphone

Google Maps API V3 - Select Fusion Table layer from drop-down list
To make things clear, I'm not using jQuery. (1) I'm using onchange="selectChange()" event for SELECT tag and below is the code. function selectChange(){ var value = document.getElementById("street_address").value; if (value =='1') street_address1.setMap(map); else if (value =='2') street_address2.setMap(map); else if (value =='3') street_address2.setMap(map); else street_address1.setMap(null); document.getElementById("street_address").removeAttribute("disabled"); }; Here I've optimized your if..else.. statement. (2) onload="init();" is a small piece of code and hence make it simple. function init() { map = new google.maps.Map(document.getElementById('map_canvas'), { center: center, zoom: 6, mapTypeId: goo

Categories : Javascript

How to change a Fusion Table layer query based on user input and button?
The map updates immediately because there is an event associated to the select element in the sample: google.maps.event.addDomListener(document.getElementById('delivery'), 'change', function() { updateMap(layer, tableId, locationColumn); }); The above code associates an event - On 'change' of the selected value, execute 'updateMap'. You need to remove this event and associate an event to your button 'click'. Example: google.maps.event.addDomListener(document.getElementById('<Your Button ID>'), 'click', function() { updateMap(layer, tableId, locationColumn); }); Having said that, your technique of attaching the event is incorrect. If you are using Javascript, you need to attach the event and add an event listener. If you

Categories : Javascript

how to do a fade-in effect for one layer after another layer, CALayer
Tag your image views with e.g. 10, 20, 30. Then, -(void)addAnimationToView:(UIView*)image { CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"]; animation.fromValue = [NSNumber numberWithFloat:0.0]; animation.toValue = [NSNumber numberWithFloat:1.0]; animation.duration = 4; animation.removedOnCompletion = NO; animation.fillMode = kCAFillModeBoth; [imageView.layer addAnimation:animation forKey:@"opacityAnimation"]; } for (int i=0; i<3; i++) { UIImageView *image = (UIImageView*) [self.view viewWithTag:(i+1)*10]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, i*4 * NSEC_PER_SEC), dispatch_get_current_queue(), ^{ [self addAnimationToView:image]; }); } Maybe you have to prefix the definition of image with __

Categories : IOS

Switching backgrounds, while switching text
Why do you want to change the id of the element if you are so keen to set the color. You can just the class on the body element which should get the work done for you. Secondly it's a bad practice to bind events inline. Use javascript to bind the events as well. <body id="color1" class="color1"> This is one way of writing the code. Code var header = document.getElementsByTagName('header')[0]; header.addEventListener('click', function () { var body = document.getElementById('color1'); document.getElementById('click').innerHTML = flip("text"); body.className = flip("color"); }); var flip = (function () { var flip = ['_addText1', '_addText2', '_addText3'], colors = ["color1", "color2", "color3"]; var count = -1, colorCount = -1; return

Categories : Javascript

Multiply matrices layer by layer
Haven't benchmarked this (so this is not guaranteed to be faster), but here goes: [L, ma, na] = size(A); [L, mb, nb] = size(B); AX = reshape(permute(A, [2 1 3]), [], na); BX = reshape(permute(B, [2 3 1]), mb, []); CX = reshape(permute(reshape(AX * BX, ma, L, nb, L), [1 3 2 4]), ma, nb, []); C = permute(CX(:, :, 1:L + 1:end), [3 1 2]); Note that you might also run into memory problems if A and B are large (in which case you'll have to resort to loops).

Categories : Matlab

cant add a shape layer into a view's layer
add a path to it, like shapeLayer.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 2.0*radius, 2.0*radius) cornerRadius:radius].CGPath; A shaped layer needs a shape… I put this in my View Controller and it works fine: - (void)viewDidLoad { [super viewDidLoad]; CAShapeLayer *shapeLayer = [CAShapeLayer layer]; shapeLayer.frame = CGRectMake(150, 50, 200, 200); shapeLayer.fillColor = [UIColor whiteColor].CGColor; shapeLayer.strokeColor = [UIColor orangeColor].CGColor; NSUInteger radius = 90; shapeLayer.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 2.0*radius, 2.0*radius) cornerRadius:radius].CGPath; [self.view.layer addSubl

Categories : IOS

How to inject Service Layer into controller when service layer depends upon repository and UnitOfWork
There's a lot opinions on this but this is how I worked it out for myself UnitOfWork public interface IUnitOfWork : IDisposable { FooContext DbContext { get; } void Save(); } public class UnitOfWork : IUnitOfWork { protected string ConnectionString; private FooContext context; public UnitOfWork(string connectionString) { this.ConnectionString = connectionString; } public FooContext DbContext { get { if (context == null) { context = new FooContext(ConnectionString); } return context; } } ... } GenericRepository public class GenericRepository<TEntity> : IGenericRepository<TEntity> where TEntity : class { protected FooContext Db

Categories : Asp Net Mvc

Create service response in web method, service layer or DAO layer?
I would say in your web method. The web service should be the interface for calling the service layer. It should transform the incoming request into something the service layer understands and should transform the result into something the web service can send. The service is, in general, a reusable part of your application and could be reused between your web service and web application (with controllers) or maybe by doing batch inserts. Basically everything calling the service (which contains the business logic) is a interfacing layer to your service. Controllers provide access to the application behavior that you typically define through a service interface. Controllers interpret user input and transform it into a model that is represented to the user by the view. Spring implemen

Categories : Java

I have two table called Event table and Date table.I want to show following display table without duplicating rows using sql
Try this: For MySQL SELECT EVENT_NAME, REPLACE(REPLACE(DATE_FORMAT(START_DATE, '%Y/%m/%d %h:%i:%s %p'), 'AM', 'a.m.'), 'PM', 'p.m.') START_DATE, CONCAT(REPLACE(REPLACE(DATE_FORMAT(START_DATE, '%Y/%m/%d %h:%i:%s %p'), 'AM', 'a.m.'), 'PM', 'p.m.'), ' - ', REPLACE(REPLACE(DATE_FORMAT(END_DATE, '%Y/%m/%d %h:%i:%s %p'), 'AM', 'a.m.'), 'PM', 'p.m.')) FROM_TO FROM (SELECT ET.EVENT_NAME, MIN(STR_TO_DATE(REPLACE(ET.START_DATE, '.', ''), '%Y/%m/%d %h:%i:%s %p')) START_DATE, MAX(STR_TO_DATE(REPLACE(ET.START_DATE, '.', ''), '%Y/%m/%d %h:%i:%s %p')) END_DATE FROM EVENT_TABLE ET INNER JOIN DATE_TABLE DT ON ET.E_ID = DT.E_ID GROUP BY ET.E_ID ) AS A;

Categories : Mysql

Switching between RTL and LTR in android
you can make it this when create xmls in arabic (/res/Layout-ar) and another xmls in XML (/res/Layout) and the same thing in drawable , values. i think this is the perfect method to create multilingual App . you can customize textview and radio button ,..... from when write gravity = right if its arabic example radioButton in arabic: <RadioButton android:id="@+id/radio1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:layout_marginTop="5dp" android:button="@drawable/radiobutton_selector" android:gravity="right" />

Categories : Android

C# WPF page switching
Here is a small workaround. Original sources I found here: http://social.msdn.microsoft.com/Forums/vstudio/en-us/843677f4-8f0b-46cb-986c-92e8042d0707/stupid-problem-with-webbrowser-control using System.Windows; using System.Windows.Controls; using Microsoft.Win32; namespace WpfApplication1 { /// <summary> /// Interaction logic for Page1.xaml /// </summary> public partial class Page1 : Page { private RegistryKey regKeyCurrentUser; private RegistryKey regSubKeyCurrent; public Page1() { InitializeComponent(); } private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { var page2 = new Page2(); this.NavigationService.Navigate(page2); } privat

Categories : C#

Switching between two UITabBarController?
If you add a Restoration ID to your viewControllers in the storyboard (identity inspector) you can instantiate a controller by calling the method instantiateViewControllerWithIdentifier: In your case, maybe i would have instantiate a parent view controller, and when wanting to swap of tabBarcontroller, I would have called [parentViewController.storyboard instantiateViewControllerWithIdentifier:@"tabBarController2"]; And then change controller displayed. (Not tested, just some ideas...)

Categories : IOS

Yii switching to HTTPS
Rewrite conditions only affect the immediately following rule. The two !-f and !-d conditions need to be applied to the routing rule: RewriteRule . index.php. Otherwise, everything blindly gets routed to index.php and request for files that actually exist won't get fulfilled. Additionally, the redirect needs to be before the routing rule, so you need to move your conditions to be right above your routing rule: RewriteEngine on # manual change the url base RewriteBase / RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://my.domain.de/$1 [R,L] # if a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # otherwise forward it to index.php RewriteRule . index.php

Categories : Htaccess

Switching between viewmodels
Switching VMs is not the route to go mostly due to data binding. Each page should have its own VM. That doesn't mean you can't share VMs though. Have the main page VM have each other VM, then when you switch, take that change into account with the data bindings.

Categories : C#

Switching GridbagLayout on the fly
Try removing the old components from their container first: public void newLayout1() { timeTablePnl.remove(jb1); timeTablePnl.remove(jb2); timeTablePnl.remove(jb3); . . . } I think GridBagLayout simply ignores components inserted at the same grid coordinate otherwise.

Categories : Java

Switching between three views
A Page curl is not ment to show the entire screen, it is only ment for half or 3/4 of the screen, like in the Maps.app. If you are looking to change it, i suggest using the "Flip Horizontal" animation in this case.

Categories : IOS

Is glEnable kept when switching FBO?
No, GL_CULL_FACE and other rasterization state are not stored per framebuffer object. Indeed you need only to setup the state only once. To check this fact, you can read the specification of the state in the chapter 23 (State tables) of the OpenGL specification. The table defines the state of each framebuffer object.

Categories : Opengl

What do I have to take care of when switching from ws:// to wss://
the only real "negative" impact might be a slight increase in CPU utilization needed to do the encryption/decryption of the content you are sending. some of this can be offset by choosing a weaker (re:faster) cipher or in extreme cases, using an SSL hardware-based offload. there's also just a little added latency in establishing the connection (similar to using HTTPS of course) because of the TLS key exchange. but because the key-exchange handshake only needs to happen once on the connection, it's not such a big cost overall. as you've noted, you'll also need to get appropriate SSL certs so this will be an added administrative cost (both in $$ if you get it signed by a recognized certificate authority and a bit of time in loading it up into some keystore). agreed with phil (@leggetter

Categories : Javascript

Penalty for switching from SSE to AVX?
I did not test your code, but since your test appears quite short, maybe you're seeing the Floating point warm-up effect that Agner Fog discusses on p.101 of his microarchitecture manual (this applies to Sandy Bridge architecture). I quote: The processor is in a cold state when it has not seen any floating point instructions for a while. The latency for 256-bit vector additions and multiplications is initially two clocks longer than the ideal number, then one clock longer, and after several hundred floating point instructions the processor goes to the warm state where latencies are 3 and 5 clocks respectively. The throughput is half the ideal value for 256-bit vector operations in the cold state. 128-bit vector operations are less affected by this warm-up effect. The la

Categories : C++

C# switching windows in .net
SwitchToThisWindow is expecting a handle to the window that you want to switch to in that process. Try SwitchToThisWindow(proc.MainWindowHandle);

Categories : C#

Switching tabs from IE BHO C++
There's no public interface for doing this; you can use an undocumented object as shown in this project: http://www.codeproject.com/Articles/5079/Mouse-Gestures-for-Internet-Explorer or you could synthesize a keystroke (e.g. CTRL+TAB or CTRL+SHIFT+TAB) to cause IE to switch tabs on your behalf.

Categories : Internet Explorer

Input switching in C
you can't compare strings with == you have to use strcmp(char *string1,char*string2) you can do like that : char input[20]; int resul[4]; scanf("%s%d%d",input,&resul[0],&resul[1]); if (input[0]=='r') scanf("%d%d",&resul[2],&resul[3]);

Categories : C

Switching to tabBarController but no tab bar
You can change rootViewController property of mainWindow of AppDelegate some thing like this. AppDelegate * appDel = (AppDelegate*)[[UIApplication sharedApplication] delegate]; [appDel.window setRootViewController:tabBarController]; Enjoy..

Categories : Iphone

how to fetch particular record from table X joining table Y or table Z where table Y and Z has same column name with same kind of data?
Assuming that the child record will ALWAYS be in either equipment or equipment2, but never both, you could just add equipment2 with an outer join, and use NVL() to pick the not null value: SELECT TO_CHAR (a.LOG_DATE, 'mm/dd/yyyy HH:MI:SS') LOG_DATE, nvl(b.id,b2.id), a.atid, a.l_type, a.l_subtype, a.eq, a.name, a.comments FROM log a, equipment b, equipment2 b2 WHERE a.eqid = b.eqid(+) AND a.eqid = b2.eqid(+) AND log_date BETWEEN TO_DATE ('07/01/2013', 'MM/DD/YYYY') AND TO_DATE ('07/08/2070', 'MM/DD/YYYY') ORDER BY 2 This also assumes that you're only picking a column that will not be populated with a NULL. If, for example, equipment/equipment2 also contains a "name" column that might be null, you'd need some additional logic: case when b.

Categories : SQL

'Switching' a Tel: link on and off... Preferably CSS only
There really isn't anything wrong with leaving the link on desktop computers. This would for example allow you to click the link to call via Skype or other VOIP program you might have installed. If you still want to change the link, just create two of them. One that is shown for desktops, the other for mobiles.

Categories : HTML

Switching to Base Internationaliztion
This tutorial drives you through the process step-by-step. This is how it worked for me: Remove all localizations and leave only the base. Ensure that the localized files were moved from the project directory (in Finder) Add the localizations one-by-one The localized strings are extracted from the storyboard only when the localization is created. The Tutorial above provides a script that can help you keeping the localized files up to date if the storyboard is changed. In your case, you will have to merge the existing translations into the new files but I suppose it is not a huge deal compared to the gain with using a single file. For reference, the process is described in this official tutorial too: http://developer.apple.com/library/ios/referencelibrary/GettingStarted/RoadMapiOS/cha

Categories : Iphone

Android App switching activities
Probably the reason is manifest xml file changes. Here is a sample, enter this under application tag ; <activity android:name="mete.gcm.info" android:theme="@style/AppTheme"></activity> mete.gcm is my folder name (under src folder) info is my activity name.

Categories : Java

Switching between different workbooks without using .activate
Taken from the msdn site for the Workbooks property: "Returns a Workbooks collection that represents all the open workbooks. Read-only." hence the last line of your code gives you an error since the file is not open. AFAIK, you cannot reference objects within a workbook if that workbook is not open. You can access whatever a workbook has without activating it (so without using .Activate), but it has to be open. Maybe this SO question is of help to you: Open Excel file for reading with VBA without display If your workbook is open, you can do the following: Dim wBook as Excel.Workbook, rngTemp as range Set wBook = workbooks("wbName.xls") With wBook ' Do stuff, no need to activate. Example: set rngTemp=.sheets(1).usedRange End With I hope this helps?

Categories : Excel

NoSuchElementException after switching frames
I think your problem is the following: This line: driver.get(baseUrl + "/something.com"); says him to go to this page, and the second line says him to search for the element immediately (so the browser dont have time at all to load the page) So try this: WebDriverWait wait; wait = new WebDriverWait(webdriver, 10); try{ wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("user"))); }catch(TimeoutException e){ verifyElementPresent(locator); } or: for (int second = 0;; second++) { if (second >= 60) fail("timeout"); try { if (isElementPresent(By.name("user"))) { break; } } catch (Exception e) { } Thread.sleep(1000); }

Categories : Java

Keep pageranks switching to Wordpress
Try this tutorial. It's not quite the same, but it's going to talk you through the important parts of a transfer to minimize loss of SEO. Basically make sure you keep all the current links to your pages working after the transfer. Import all posts, comments & pages. Maintaining permalinks for posts & pages (1-on-1 mapping between Blogger.com and WordPress pages). Redirecting permalinks for labels & search archives. Retaining all feed subscribers.

Categories : HTML

switching database with mongoose
It is asynchronous. If you pass a callback function to disconnect and try to connect to the next database in that callback, it will work. Ex. var mongoose = require('mongoose') mongoose.connect('mongodb://localhost/test1', function() { console.log('Connected to test 1') mongoose.disconnect(connectToTest2) }) function connectToTest2() { mongoose.connect('mongodb://localhost/test2', function() { console.log('Connected to test 2') process.exit() }) }

Categories : Node Js



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.