Daily Archives

Articles indexed Sunday September 23 2012

Page 10/15 | < Previous Page | 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • creating a pre-menu level select screen

    - by Ephiras
    Hi I am working on creating a tower Defence java applet game and have come to a road block about implementing a title screen that i can select the level and difficulty of the rest of the game. my title screen class is called Menu. from this menu class i need to pass in many different variables into my Main class. i have used different classes before and know how to run them and such. but if both classes extend applet and each has its individual graphics method how can i run things from Main even though it was created in Menu. what i essentially want to do is run the Menu class withits action listeners and graphics until a Difficulty button has been selected, run the main class (which 100% works without having to have the Menu class) and pretty much terminate Menu so that i cannot go back to it, do not see its buttons or graphics menus. can i run one applet annd when i choose a button close that one and launch the other one? IF you would like to download the full project you can find it here, i had to comment out all the code that wasn't working my Menu class import java.awt.*; import java.awt.event.*; import java.applet.*; public class Menu extends Applet implements ActionListener{ Button bEasy,bMed,bHard; Main m; public void init(){ bEasy= new Button("Easy"); bEasy.setBounds(140,200,100,50); add(bEasy); bMed = new Button("Medium");bMed.setBounds(280,200,100,50); add(bMed); bHard= new Button("Hard");bHard.setBounds(420,200,100,50); add(bHard); setLayout(null); } public void actionPerformed(ActionEvent e){ Main m = new Main(20,10,3000,mapMed);//break; switch (e.getSource()){ case bEasy: Main m = new Main(6000,20,"levels/levelEasy.png");break;//enimies tower money world case bMed: Main m = new Main(4000,15,"levels/levelMed.png");break; case bHard: Main m = new Main(2000,10,"levels/levelEasy.png");break; default: break; } } public void paint(){ //m.draw(g) } } and here is my main class initialising code. import java.awt.*; import java.awt.event.*; import java.applet.*; import java.io.IOException; public class Main extends Applet implements Runnable, MouseListener, MouseMotionListener, ActionListener{ Button startButton, UpgRange, UpgDamage; //set up the buttons Color roadCol,startCol,finCol,selGrass,selRoad; //set up the colors Enemy e[][]; Tower t[]; Image towerpic,backpic,roadpic,levelPic; private Image i; private Graphics doubleG; //here is the world 0=grass 1=road 2=start 3=end int world[][],eStartX,eStartY; boolean drawMouse,gameEnd; static boolean start=false; static int gridLength=15; static int round=0; int Mx,My,timer=1500; static int sqrSize=31; int towers=0,towerSelected=-10; static int castleHealth=2000; String levelPath; //choose the level Easy Med or Hard int maxEnemy[] = {5,7,12,20,30,15,50,30,40,60};//number of enimies per round int maxTowers=15;//maximum number of towers allowed static int money =2000,damPrice=600,ranPrice=350,towerPrice=700; //money = the intial ammount of money you start of with //damPrice is the price to increase the damage of a tower //ranPrice is the price to increase the range of a tower public void main(int cH,int mT,int mo,int dP,int rP,int tP,String path,int[] mE)//constructor 1 castleHealth=cH; maxTowers=mT; money=mo; damPrice=dP; ranPrice=rP; towerPrice=tP; String levelPath=path; maxEnemy = mE; buildLevel(); } public void main(int cH,int mT,String path)//basic constructor castleHealth=cH; maxTowers=mT; String levelPath=path; maxEnemy = mE; buildLevel(); } public void init(){ setSize(sqrSize*15+200,sqrSize*15);//set the size of the screen roadCol = new Color(255,216,0);//set the colors for the different objects startCol = new Color(0,38,255); finCol = new Color(255,0,0); selRoad = new Color(242,204,155);//selColor is the color of something when your mouse hovers over it selGrass = new Color(0,190,0); roadpic = getImage(getDocumentBase(),"images/road.jpg"); towerpic = getImage(getDocumentBase(),"images/tower.png"); backpic = getImage(getDocumentBase(),"images/grass.jpg"); levelPic = getImage(getDocumentBase(),"images/level.jpg"); e= new Enemy[maxEnemy.length][];//activates all of the enimies for (int r=0;r<e.length;r++) e[r] = new Enemy[maxEnemy[r]]; t= new Tower[maxTowers]; for (int i=0;i<t.length;i++) t[i]= new Tower();//activates all the towers for (int i=0;i<e.length; i++)//sets all of the enimies starting co ordinates for (int j=0;j<e[i].length;j++) e[i][j] = new Enemy(eStartX,eStartY,world); initButtons();//initialise all the buttons addMouseMotionListener(this); addMouseListener(this); }

    Read the article

  • Island Generation Library

    - by thatguy
    Can anyone recommend a tile map generator (written in Java is a plus), where one can control some land types? For example: islands, large continents, singe large continent, archipelago, etc. I've been reading through many posts on the subject, it almost seems like many are just rolling their own. Before creating my own, I'm wondering if there's already an open source implementation that I might not be finding. If not, it seems like using Perlin Noise is a popular choice. Some articles I've been reading: http://simblob.blogspot.com/2010/01/simple-map-generation.html Generate islands/continents with simplex noise https://sites.google.com/site/minecraftlandgenerator/

    Read the article

  • Making body(box2d) a spite(andengine) in android

    - by Kadir
    I can't make body(box2d) a spite(andengine) and at the same time i wanna apply MoveModifier to sprite which is body.if i can make just body,it works namely the srites can collide.if i can apply just MoveModifier to sprites,the sprites can move where i want.but i wanna make body(they can collide) and apply MoveModifier(they can move where i want) at the same time.How can i do? this my code just run MoveModifier not as body at the same time. circles[i] = new Sprite(startX, startY, textRegCircle[i]); body[i] = PhysicsFactory.createCircleBody(physicsWorld, circles[i], BodyType.DynamicBody, FIXTURE_DEF); physicsWorld.registerPhysicsConnector(new PhysicsConnector(circles[i], body[i], true, true)); circles[i].registerEntityModifier( (IEntityModifier) new SequenceEntityModifier ( new MoveModifier(10.0f, circles[i].getX(), circles[i].getX(), circles[i].getY(),CAMERA_HEIGHT+64.0f))); scene.getLastChild().attachChild(circles[i]); scene.registerUpdateHandler(physicsWorld);

    Read the article

  • Quick-sort doesn't work with middle pivot element

    - by Bobby
    I am trying to sort an array of elements using quick-sort algorithm.But I am not sure where am I going wrong.I choose the middle element as pivot every time and then I am checking the conditions.Here is my code below. void quicksort(int *temp,int p,int r) { if(r>p+1) { int mid=(p+r)/2; int piv=temp[mid]; int left=p+1; int right=r; while(left < right) { if(temp[left]<=piv) left++; else swap(&temp[left],&temp[--right]); } swap(&temp[--left],&temp[p]); quicksort(temp,p,left); quicksort(temp,right,r); } }

    Read the article

  • How to change TextView background color when touching in and out of view?

    - by MikeShiny
    This has to be a very simple fix, but I can't seem to figure it out. I have got my program to change the background color to change onClick, and onTouch with ACTION_DOWN and ACTION_UP. But I need it to change the color when touching the screen and going in and out of the TextView. I need it to function like a mouseOver/mouseOut event. Is there a way to do this on android? Or am I stuck with onTouch, where the action has to start from within the TextView? Right now I set the onTouch Listener on the textview itself. Should I set it somewhere else and then check if the x and y are within the Textview? Or is there another event listener I should be using? I am new to Android, any help would be appreciated. Thanks. Mike

    Read the article

  • UICollectionViewCell imageView

    - by Flink
    Code works fine until I changed UIViewController with tableView to UICollectionViewController. Now all cells shows same image, sometimes it flipping to nil. However textLabels are OK. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"TourGridCell"; TourGridCell *cell = (TourGridCell *)[collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath]; Guide *guideRecord = [self.fetchedResultsController objectAtIndexPath:indexPath]; cell.titleLabel.text = [guideRecord.name uppercaseString]; cell.titleLabel.backgroundColor = [UIColor clearColor]; if ([guideRecord.sights count] > 0) { if ([[guideRecord.sights objectAtIndex:0]valueForKey:@"thumbnail"]) { cell.imageView.image = [UIImage drawImage:[[guideRecord.sights objectAtIndex:0]valueForKey:@"thumbnail"] inImage:[UIImage imageNamed:@"MultiplePhotos"] inRect:CGRectMake(11, 11, 63, 63)]; }else { cell.imageView.image = [UIImage imageNamed:@"placeholder2"]; } NSMutableString *sightsSummary = [NSMutableString stringWithCapacity:[guideRecord.sights count]]; for (Sight *sight in guideRecord.sights) { if ([sight.name length]) { if ([sightsSummary length]) { [sightsSummary appendString:@", "]; } [sightsSummary appendString:sight.name]; } } if ([sightsSummary length]) { [sightsSummary appendString:@"."]; } cell.sightsTextLabel.text = sightsSummary; cell.detailTextLabel.text = [NSString stringWithFormat:NSLocalizedString(@"%i", nil) , [guideRecord.sights count]]; cell.detailTextLabel.hidden = NO; // cell.textLabel.alpha = 0.7; NSPredicate *enabledSightPredicate = [NSPredicate predicateWithFormat:@"notify == YES"]; NSArray *sightsEnabled = [[[guideRecord.sights array] filteredArrayUsingPredicate:enabledSightPredicate]mutableCopy]; NSPredicate *visitedSightPredicate = [NSPredicate predicateWithFormat:@"visited == YES"]; NSArray *sightsVisited = [[[guideRecord.sights array] filteredArrayUsingPredicate:visitedSightPredicate]mutableCopy]; if ([sightsEnabled count] > 0) { NSLog(@"green_badge"); cell.notifyIV.image = [UIImage imageNamed:@"green_badge"]; } else if (sightsVisited.count == 0) { NSLog(@"new_badge"); cell.notifyIV.image = [UIImage imageNamed:@"new_badge"]; } else { cell.notifyIV.image = nil; } } else { cell.notifyIV.hidden = YES; // cell.textLabel.textColor = RGB(0, 50, 140); cell.detailTextLabel.hidden = YES; cell.sightsTextLabel.text = nil; } return cell; }

    Read the article

  • Nicely printing/showing a binary tree in Haskell

    - by nicole
    I have a tree data type: data Tree a b = Branch b (Tree a b) (Tree a b) | Leaf a ...and I need to make it an instance of Show, without using deriving. I have found that nicely displaying a little branch with two leaves is easy: instance (Show a, Show b) => Show (Tree a b) where show (Leaf x) = show x show (Branch val l r) = " " ++ show val ++ "\n" ++ show l ++ " " ++ show r But how can I extend a nice structure to a tree of arbitrary size? It seems like determining the spacing would require me to know just how many leaves will be at the very bottom (or maybe just how many leaves there are in total) so that I can allocate all the space I need there and just work 'up.' I would probably need to call a size function. I can see this being workable, but is that making it harder than it is?

    Read the article

  • How to use a class's type as the type argument for an inherited collection property in C#

    - by Edelweiss Peimann
    I am trying to create a representation of various types of card that inherit from a generic card class and which all contain references to their owning decks. I tried re-declaring them, as suggested here, but it still won't convert to the specific card type. The code I currently have is as such: public class Deck<T> : List<T> where T : Card { void Shuffle() { throw new NotImplementedException("Shuffle not yet implemented."); } } public class Card { public Deck<Card> OwningDeck { get; set; } } public class FooCard : Card { public Deck<FooCard> OwningDeck { get { return (Deck<FooCard>)base.OwningDeck; } set { OwningDeck = value; } } } The compile-time error I am getting: Error 2 Cannot convert type 'Game.Cards.Deck' to 'Game.Cards.Deck' And a warning suggesting I use a new operator to specify that the hiding is intentional. Would doing so be a violation of convention? Is there a better way? My question to stackoverflow is this: Can what I am trying to do be done elegantly in the .NET type system? If so, can some examples be provided?

    Read the article

  • Jquery StopPropagation not working in firefox

    - by Karim Mortabit
    I have this code working on Safari and Chrome , but not in Firefox . Is firefox having a problem with StopPropagation() ? $(function() { // Setup drop down menu $('.dropdown-toggle').dropdown(); // Fix input element click problem $('.login-menu form').click(function(e) { alert( e.isPropagationStopped() ); e.stopPropagation(); alert( e.isPropagationStopped() ); }); });

    Read the article

  • need explaination of jquery ajax.success paramters

    - by user1575229
    case 'ajax': busy = false; $.fancybox.showActivity(); selectedOpts.ajax.win = selectedOpts.ajax.success; ajaxLoader = $.ajax($.extend({}, selectedOpts.ajax, { url : href, data : selectedOpts.ajax.data || {}, error : function(XMLHttpRequest, textStatus, errorThrown) { if ( XMLHttpRequest.status > 0 ) { _error(); } }, success : function(data, textStatus, XMLHttpRequest) { var o = typeof XMLHttpRequest == 'object' ? XMLHttpRequest : ajaxLoader; if (o.status == 200) { if ( typeof selectedOpts.ajax.win == 'function' ) { ret = selectedOpts.ajax.win(href, data, textStatus, XMLHttpRequest); if (ret === false) { loading.hide(); return; } else if (typeof ret == 'string' || typeof ret == 'object') { data = ret; } } tmp.html( data ); _process_inline(); } } })); break; Can anyone please explain what is going on in this code selectedOpts.ajax.win = selectedOpts.ajax.success; what is happening here?and what is the usefulness? ret = selectedOpts.ajax.win(href, data, textStatus, XMLHttpRequest); what is happening here? what does the win() method call.

    Read the article

  • Disable inserted lines in multiline TextBox

    - by Shohin
    I have a multiline Textbox for my web page. When user logs in and enters text and press "Save" button, data will be saved. Then, next time when the same user logs in and searches for data, I want him to edit only new text in multiline TextBox, not removing or replacing previously entered text. Is there any way to make multiline TextBox to lock inserted lines or inserted text and allow to only add text? Thanks in advance.

    Read the article

  • Foreach loop is running n times

    - by Furqan Khyraj
    foreach($CarAdList as $CarAd) { echo($msg .= '<tr><td>'.$CarAd->getCarAdID().'</td><td>' .$CarAd->getBrandText().'</td><td>' .$CarAd->getDescription(). '</td><td><a href="status.php?id='.$CarAd->getCarAdID().'"><img src="../images/active.png" /></a></td><td><img src="../images/delete.png" width="30px" /></td></tr>'); } e.g, the number of rows =38 n= the number of rows * the number of rows-- it is running n times so its displaying 5 5 4 5 4 3 5 4 3 2 5 4 3 2 1

    Read the article

  • Easiest way to split up a large controller file

    - by timpone
    I have a rails controller file that is too large (~900 lines - api_controller). I'd like to just split it up like something like this: api_controller.rb api_controller_item_admin.rb api_controller_web.rb I don't want to split into multiple controllers. What would be the preferred way to do this? Could I just require the new parts at the end? like: require './api_controller_item_admin' require './api_controller_web'

    Read the article

  • How can I determine if a file is read-only for my process on *nix?

    - by user109078
    Using the stat function, I can get the read/write permissions for: owner user other ...but this isn't what I want. I want to know the read/write permissions of a file for my process (i.e. the application I'm writing). The owner/user/other is only helpful if I know if my process is running as the owner/user/other of the file...so maybe that's the solution but I'm not sure of the steps to get there.

    Read the article

  • Scala Lift - Robust method to protect files from hotlinking

    - by sirjamm
    I'm attempting to implement a way to stop hotlinking and/or un-authorised access to resources within my app. The method I'm trying to add is something I've used before in PHP apps. Basically a session is set when the page is first called. The images are added to the page via the image tag with the session value as a parameter: <img src="/files/image/[handle]?session=12345" /> When the image is requested the script checks to see if the session is set and matches the provided value. If the condition is not met the serving page returns null. Right at the end to the code I unset the session so further requests from outside the scope of the page will return null. What would be the best implementation of this method within the lift framework? Thanks in advance for any help, much appreciated :)

    Read the article

  • no DOM in wordpress admin

    - by Chris
    I correctly inserted a javascript file into the wordPress admin with : wp_enqueue_script() I know that the script is loading. I tested it with an alert(). I then found that I am unable to access the DOM. When I tried : document.getElementsByTagName('body')[0].addEventListener('load', function() {}); This error was: Uncaught TypeError: Cannot call method 'addEventListener' of undefined This is the first time I have used 'settings api' or inserted scripts into the WordPress admin.

    Read the article

  • Uninstalling Android Application

    - by Sosukodo
    When I create an Android project in Eclipse and send it to my device for debugging, the app works fine but when I try to uninstall it, I get a strange message. Below are the steps to recreate my problem: Eclipse Version: 4.2.0 Build id: I20120608-1400 ADT Version: 2.0.3 v201208082019-427395 Run Eclipse Click File-New-Project... Select Android/Android Application Project Click Next. Enter Application Name: Test Build SDK: Android 4.1 Minimum Required SDK: API 8 Android 2.2 Enable: Create custom launcher icon / Create project in workspace Click Next thrice. Click Finish. Connect 4.1 Android device to computer via USB. Click Run-Run from menu. Select "Android application" on popup the "Run As" popup. Click Ok. MainActivity application runs on device. Click the Back button on the Android device. Open applications on device and find "MainActivity" app. Long press the MainActivity icon and drag to trash. Here's the puzzling part: Instead of getting a standard Do you want to uninstall this app? I get a dialog with this text: MainActivity is part of the following app: Test Do you want to uninstall this app? Why do I get this message instead of the standard one? Why is MainActivity the name of the app when I specifically stated the name of the app is "Test"?

    Read the article

  • how can I count number of occurance of a word in a string while ignoring cases

    - by Ronny
    I am trying to count the number of occurance of a given word while ignoring cases. I have tried <?php $string = 'Hello World! EARTh in earth and EARth';//string to look into. if(stristr($string, 'eartH')) { echo 'Found';// this just show eartH was found. } $timesfound = substr_count($string, stristr($string, 'eartH'));// this count how many times. echo $timesfound; // this outputs 1 instead of 3.

    Read the article

  • Porting - Shared Memory x32 & x64 processes

    - by dpb
    A 32 bit host Windows application setups shared memory (using memory mapped file / CreateFileMapping() API), and then other 32 bit client processes use this shared memory to communicate with each other. I am planning to port the host application to 64 bit platform and once it is ready, I intend that both 32 bit and 64 bit client processes should be able to use the shared memory setup by the main 64 bit host application. The original code written for host x32 application uses "size_t" almost everywhere, since this differs from 4 bytes to 8 bytes as we move from x32 to x64, I am looking for replacing it. I intend to replace "size_t" by "unsigned long long", so that its size will be same on 32 bit & 64 bit. Can you please suggest me better alternative? Also, will the use of "unsigned long long" have performance impact on x32 app .. i guess yes? Research Done - Found very useful articles - a) 20 issue in porting from 32 bit to 64 bit (www.viva64.com) b) No way to restrict/change "size_t" on x64 platform to 4 bytes using compiler flags or any hooks/crooks since it is typedef

    Read the article

  • How can I embed a conditional comment for IE with innerHTML?

    - by Samuel Charpentier
    Ok so I want to conditionally add this line of code; <!--[if ! IE]> <embed src="logo.svg" type="image/svg+xml" /> <![endif]--> Using: document.getElementById("logo") .innerHTML='...'; In a if()/else() statement and it don't write it! If i get rid of the selective comment ( <!--[if ! IE]><![endif]-->) and only put the SVG ( <embed src="logo.svg" type="image/svg+xml" /> ) it work! what should I do? I found a way around but i think in the Android browser the thing will pop up twice. here's what I've done ( and its Validated stuff!); <!DOCTYPE html> <html> <head> <META CHARSET="UTF-8"> <title>SVG Test</title> <script type="text/javascript"> //<![CDATA[ onload=function() { var ua = navigator.userAgent.toLowerCase(); var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile"); if(isAndroid) { document.getElementById("logo").innerHTML='<img src="fin_palais.png"/>'; } } //]]> </script> </head> <body> <div id="logo"> <!--[if lt IE 9]> <img src="fin_palais.png"/> <![endif]--> <!--[if gte IE 9]><!--> <embed src="fin_palais.svg" type="image/svg+xml" /> <!--<![endif]--> </div> </body>

    Read the article

  • LNK2019 Against CArray Add, GetAt, GetSize, all includes are present

    - by David J
    I'm having some issues trying to Compile a DLL, but I just can't see where this linking error is coming from. My LNK2019 is: Exports.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall CArray<struct HWND__ *,struct HWND__ *>::Add(struct HWND__ *)" (__imp_?Add@? $CArray@PAUHWND__@@PAU1@@@QAEHPAUHWND__@@@Z) referenced in function "int __stdcall _Disable(struct HWND__ *,long)" (?_Disable@@YGHPAUHWND__@@J@Z) Disable(...) is... static BOOL CALLBACK _Disable(HWND hwnd, LPARAM lParam) { CArray<HWND, HWND>* pArr = (CHWndArray*)lParam; if(::IsWindowEnabled(hwnd) && ::IsWindowVisible(hwnd)) { pArr->Add(hwnd); ::Enable(hwnd, FALSE); } } This is the first function in Exports.cpp; right above it is #include <afxtempl.h> I have the Windows 7.1 SDK installed (and have tried reinstalling both that and VS2010). The exact same project compiles perfectly fine on other machines, so it can't be the code itself.. I've spent countless errors researching, which led to desperate attempts of just changing random values in the solution file, including different Windows headers, etc. My last resort is getting to be just reinstalling the OS completely (assuming it's actually a problem with the Windows SDK being incorrect or something). Any suggestions at all would be a huge help. EDIT: I've added /showIncludes on the cpp giving issues, and I do see afxtempl.h being included. It's being included multiple times due to other headers including it, but it is there (and it is from the same directory every time): 1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxtempl.h

    Read the article

  • wso2 ESB: server configuration CRITICAL

    - by nuvio
    My Scenario: I have server_1 (192.168.10.1) with wso2-ESB and server_2 (192.168.10.2) with Glassfish-v3 + web services. Problem: I am trying to create a proxy in ESB using the java Web Services, but the created proxy does not respond properly. The log says: Unable to sendViaPost for http or https does not change the result. I think I should configure the axis2.xml but I am having trouble, and don't know what to do. What is the configuration for my scenario? Please help me! EDIT: To be clear, I can directly consume the WebService in the Glassfish server, it works normal, both port and url are accessible. Only when I create a "Pass through Proxy" in the ESB, it does not work. I don't think is matter of Proxy configuration...I never had problems while deployed locally, problems started once I have uploaded the ESB to a remote server. I really would need someone to point me what is the correct procedure when installing the ESB on a remote host: configuration of axis2.xml and carbon.xml, ports, transport receivers etc... P.S. I had a look at the official (wso2 esb and carbon) guides with no luck, but I am missing something... Endpoint of Java Web Service: http://192.168.10.2:8080/HelloWorld/Hello?wsdl ESB Proxy Enpoint: http://192.168.10.1:8280/services/HelloProxy The following is my axis2.xml configuration, please check it: <transportReceiver name="http" class="org.apache.synapse.transport.nhttp.HttpCoreNIOListener"> <parameter name="port" locked="false">8280</parameter> <parameter name="non-blocking" locked="false">true</parameter> <parameter name="bind-address" locked="false">192.168.10.1</parameter> <parameter name="WSDLEPRPrefix" locked="false">https//192.168.10.1:8280</parameter> <parameter name="httpGetProcessor" locked="false">org.wso2.carbon.transport.nhttp.api.NHttpGetProcessor</parameter> <!--<parameter name="priorityConfigFile" locked="false">location of priority configuration file</parameter>--> </transportReceiver> <!-- the non blocking https transport based on HttpCore + SSL-NIO extensions --> <transportReceiver name="https" class="org.apache.synapse.transport.nhttp.HttpCoreNIOSSLListener"> <parameter name="port" locked="false">8243</parameter> <parameter name="non-blocking" locked="false">true</parameter> <parameter name="bind-address" locked="false">192.168.10.1</parameter> <parameter name="WSDLEPRPrefix" locked="false">https://192.168.10.1:8243</parameter> <!--<parameter name="priorityConfigFile" locked="false">location of priority configuration file</parameter>--> <parameter name="httpGetProcessor" locked="false">org.wso2.carbon.transport.nhttp.api.NHttpGetProcessor</parameter> <parameter name="keystore" locked="false"> <KeyStore> <Location>repository/resources/security/wso2carbon.jks</Location> <Type>JKS</Type> <Password>wso2carbon</Password> <KeyPassword>wso2carbon</KeyPassword> </KeyStore> </parameter> <parameter name="truststore" locked="false"> <TrustStore> <Location>repository/resources/security/client-truststore.jks</Location> <Type>JKS</Type> <Password>wso2carbon</Password> </TrustStore> </parameter> <!--<parameter name="SSLVerifyClient">require</parameter> supports optional|require or defaults to none --> </transportReceiver>

    Read the article

  • Insert a list of objects using MyBatis 3

    - by T Soares
    I've tried to insert a list in a database but I've got some the error: org.springframework.jdbc.BadSqlGrammarException: SqlSession operation; bad SQL grammar []; nested exception is java.sql.SQLException: ORA-00913: too many values (...). The code that I've used: <insert id="insertListMyObject" parameterType="java.util.List" > INSERT INTO my_table (ID_ITEM, ATT1, ATT2) VALUES <foreach collection="list" item="item" index="index" open="(" close=")" separator=","> #{item.idItem, jdbcType=BIGINT}, #{item.att1, jdbcType=INTEGER}, #{item.att2, jdbcType=STRING} </foreach> </insert> My dao cals the method: SqlSessionTemplate().insert(MAPPER+".insertListMyObject", parameterList); Where the parameterList is: List<MyObjects>. Does someone have a clue about what's this error? Or if does exists a better way to do multiples inserts operation. Many thanks!

    Read the article

  • how to get day name in datetime in python

    - by gadss
    how can I get the day name (such as : Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday) in datetime in python?... here is my code in my handlers.py from django.utils.xmlutils import SimplerXMLGenerator from piston.handler import BaseHandler from booking.models import * from django.db.models import * from piston.utils import rc, require_mime, require_extended, validate import datetime class BookingHandler(BaseHandler): allowed_method = ('GET', 'POST', 'PUT', 'DELETE') fields = ('id', 'date_select', 'product_name', 'quantity', 'price','totalcost', 'first_name', 'last_name', 'contact', 'product') model = Booking def read(self, request, id, date_select): if not self.has_model(): return rc.NOT_IMPLEMENTED try: prod = Product.objects.get(id=id) prod_quantity = prod.quantity merge = [] checkDateExist = Booking.objects.filter(date_select=date_select) if checkDateExist.exists(): entered_date = Booking.objects.values('date_select').distinct('date_select').filter(date_select=date_select)[0]['date_select'] else: entered_date = datetime.datetime.strptime(date_select, '%Y-%m-%d') entered_date = entered_date.date() delta = datetime.timedelta(days=3) target_date = entered_date - delta day = 1 for x in range(0,7): delta = datetime.timedelta(days=x+day) new_date = target_date + delta maximumProdQuantity = prod.quantity quantityReserve = Booking.objects.filter(date_select=new_date, product=prod).aggregate(Sum('quantity'))['quantity__sum'] if quantityReserve == None: quantityReserve = 0 quantityAvailable = prod_quantity - quantityReserve data1 = {'maximum_guest': maximumProdQuantity, 'available': quantityAvailable, 'date': new_date} merge.append(data1) return merge except self.model.DoesNotExist: return rc.NOT_HERE in my code: this line sets the date: for x in range(0,7): delta = datetime.timedelta(days=x+day) new_date = target_date + delta

    Read the article

  • Cannot Display Chinese Character in my PHP code

    - by Jun1st
    I want to display my Twitter Info in my blog. So I write some code to get it. the issue I got is that Chinese characters displayed as unknown code. Here is the test code. Could anyone take a look and help? Thanks <html> <title>Twitter Test</title> <body> <?php function mystique_objectToArray($object){ if(!is_object($object) && !is_array($object)) return $object; if(is_object($object)) $object = get_object_vars($object); return array_map('mystique_objectToArray', $object); } define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' ); require_once('/home/jun1st/jun1stfeng.com/wp-includes/class-snoopy.php'); $snoopy = new Snoopy; $response = @$snoopy->fetch("http://twitter.com/users/show/jun1st.json"); if ($response) $userdata = json_decode($snoopy->results, true); else $error = true; $response = @$snoopy->fetch("http://twitter.com/statuses/user_timeline/jun1st.json"); if ($response) $tweets = json_decode($snoopy->results, true); else $error = true; if(!$error): // for php < 5 (included JSON returns object) $userdata = mystique_objectToArray($userdata); $tweets = mystique_objectToArray($tweets); $twitdata = array(); $twitdata['user']['profile_image_url'] = $userdata['profile_image_url']; $twitdata['user']['name'] = $userdata['name']; $twitdata['user']['screen_name'] = $userdata['screen_name']; $twitdata['user']['followers_count'] = $userdata['followers_count']; $i = 0; foreach($tweets as $tweet): $twitdata['tweets'][$i]['text'] = $tweet['text']; $twitdata['tweets'][$i]['created_at'] = $tweet['created_at']; $twitdata['tweets'][$i]['id'] = $tweet['id']; $i++; endforeach; endif; // only show if the twitter data from the database is newer than 6 hours if(is_array($twitdata['tweets'])): ?> <div class="clear-block"> <div class="avatar"><img src="<?php echo $twitdata['user']['profile_image_url']; ?>" alt="<?php echo $twitdata['user']['name']; ?>" /></div> <div class="info"><a href="http://www.twitter.com/jun1st"><?php echo $twitdata['user']['name']; ?> </a><br /><span class="followers"> <?php printf(__("%s followers","mystique"),$twitdata['user']['followers_count']); ?></span></div> </div> <ul> <?php $i = 0; foreach($twitdata['tweets'] as $tweet): $pattern = '/\@(\w+)/'; $replace = '<a rel="nofollow" href="http://twitter.com/$1">@$1</a>'; $tweet['text'] = preg_replace($pattern, $replace , $tweet['text']); $tweet['text'] = make_clickable($tweet['text']); // remove +XXXX $tweettime = substr_replace($tweet['created_at'],'',strpos($tweet['created_at'],"+"),5); $link = "http://twitter.com/".$twitdata['user']['screen_name']."/statuses/".$tweet['id']; echo '<li><span class="entry">' . $tweet['text'] .'<a class="date" href="'.$link.'" rel="nofollow">'.$tweettime.'</a></span></li>'; $i++; if ($i == $twitcount) break; endforeach; ?> </ul> <? endif?> ?> </body> </html>

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15  | Next Page >