Search Results

Search found 4088 results on 164 pages for 'params keyword'.

Page 41/164 | < Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >

  • Spring Stripes framework problem

    - by ali
    I am new to stripes and am attempting to integrate spring into stripes In the following code : public class ContactFormActionBeanTest { private static MockServletContext mockServletContext; private static MockHttpSession mockSession; @BeforeClass public static void setup() throws Exception { mockServletContext = new MockServletContext("webmail"); Map<String,String> params = new HashMap<String,String>(); params.put("ActionResolver.Packages", "stripesbook.action"); params.put("Extension.Packages", "stripesbook.ext," + "net.sourceforge.stripes.integration.spring"); mockServletContext.addFilter(StripesFilter.class, "StripesFilter", params); mockServletContext.setServlet(DispatcherServlet.class, "DispatcherServlet", null); mockSession = new MockHttpSession(mockServletContext); mockServletContext.addInitParameter("contextConfigLocation", "/WEB-INF/applicationContext-test.xml"); ContextLoaderListener springContextLoader = new ContextLoaderListener(); springContextLoader.contextInitialized( new ServletContextEvent(mockServletContext)); // Load mock user MockRoundtrip trip = new MockRoundtrip(mockServletContext, MockDataLoaderActionBean.class, mockSession); trip.execute(); // Login mock user trip = new MockRoundtrip(mockServletContext, LoginActionBean.class, mockSession); trip.setParameter("username", "freddy"); trip.setParameter("password", "nadia"); trip.execute("login"); } I get null in springContextLoader ContextLoaderListener springContextLoader = new ContextLoaderListener(); and test fails. Am I missing something? I am using eclipse with maven. Also when I try to deploy it for tomcat 6.0 I get following warnings: WARN net.sourceforge.stripes.util.ResolverUtil - Could not examine class 'stripesbook/ext/ContactFormatter.class' due to a java.lang.UnsupportedClassVersionError with message: Bad version number in .class file (unable to load class stripesbook.ext.ContactFormatter) I have checked to be sure that I am compiling with Java 5(set JDK compiler to 1.5) instead of 1.6 (Java 6); but didn't work out for me and still have problems running spring-stripes integrated project.

    Read the article

  • Remove a tag type from the view

    - by user284194
    I have an index view that lists all of the tags for my Entry and Message models. I would like to only show the tags for Entries in this view. I'm using acts-as-taggable-on. Tags Controller: def index @letter = params[:letter].blank? ? 'a' : params[:letter] @tagged_entries = Tagging.find_all_by_taggable_type('Entry').map(&:taggable) #@tagged_messages = Tagging.find_all_by_taggable_type('Message') #@tagged_messages = Tagging.find_all_by_taggable_type('Message').map(&:taggable) @title = "Tags" if params[:letter] == '#' @data = Tag.find(@tagged_entries, :conditions => ["name REGEXP ?", "^[^a-z]"], :order => 'name', :select => "id, name") else @data = Tag.find(@tagged_entries, :conditions => ["name LIKE ?", "#{params[:letter]}%"], :order => 'name', :select => "id, name") end respond_to do |format| flash[:notice] = 'We are currently in Beta. You may experience errors.' format.html end end tags#index: <% @data.each do |t| %> <div class="tag"><%= link_to t.name.titleize, tag_path(t) %></div> <% end %> I want to show only the taggable type 'Entry' in the view. Any ideas? Thank you for reading my question.

    Read the article

  • storing data at remote server using php

    - by VIPUL GOYAL
    I want to send data to php file and execute insert query in it to store data in database. When i execute this code, it executes but database does not get updated. Code of PHP file Java code------------------------------Remote.java------------------------------ public class Remote extends Activity { EditText name; Button s; String r; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); name= (EditText)findViewById(R.id.editText1); s=(Button)findViewById(R.id.button1); s.setOnClickListener(new OnClickListener() { public void onClick(View v) { try { r = name.getText().toString(); ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>(); postParameters.add(new BasicNameValuePair("username", r)); CustomHttpClient.executeHttpPost("http://vipul.eu5.org/abc.php", postParameters); //Enetr Your remote PHP,ASP, Servlet file link } catch (Exception e) { e.printStackTrace(); } } }); } } -----------------------------CustomHttpClient.java---------------------------- public class CustomHttpClient { private static HttpClient getHttpClient() { if (mHttpClient == null) { mHttpClient = new DefaultHttpClient(); final HttpParams params = mHttpClient.getParams(); HttpConnectionParams.setConnectionTimeout(params, HTTP_TIMEOUT); HttpConnectionParams.setSoTimeout(params, HTTP_TIMEOUT); ConnManagerParams.setTimeout(params, HTTP_TIMEOUT); } return mHttpClient; } /** * Performs an HTTP Post request to the specified url with the * specified parameters. * * @param url The web address to post the request to * @param postParameters The parameters to send via the request * @return The result of the request * @throws Exception */ public static void executeHttpPost(String url, ArrayList postParameters) throws Exception { try { HttpClient client = getHttpClient(); HttpPost request = new HttpPost(url); UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(postParameters); request.setEntity(formEntity); HttpResponse response = client.execute(request); } catch(Exception e) { } } }

    Read the article

  • PHP .htaccess issue, specific/dynamic keywords

    - by Kunal
    Here goes my .htaccess file's content. Options +FollowSymLinks RewriteEngine On RewriteRule ^online-products$ products.php?type=online RewriteRule ^land-products$ products.php?type=land RewriteRule ^payment-methods$ payment-methods.php RewriteRule ^withdrawal-methods$ withdrawal-methods.php RewriteRule ^deposit-methods$ deposit-methods.php RewriteRule ^product-bonuses$ product-bonuses.php RewriteRule ^law-and-regulations$ law-and-regulations.php RewriteRule ^product-news$ product-news.php RewriteRule ^product-games$ product-games.php RewriteRule ^no-products$ no-products.php RewriteRule ^page-not-found$ notfound.php RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^casinos/(.*)$ product.php?id=$1 RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^(.*)$ cms.php?link=$1 ErrorDocument 404 /notfound.php What I am trying to achive here is that the first set of rules apply to some specific keywords which should redirect to specific hard coded pages. But anything else parat from those keywords should redirect to cms.php as a parameter as you can see. But the problem is that every keyword is getting redirected to cms.php. Whereas I want any other keyword apart from which are already hard coded in .htaccess file should go cms.php. Not just every keyword. Example: www.sitename.com/online-products -> www.sitename.com/products.php?type=online www.sitename.com/about-the-website -> www.sitename.com/cms.php?id=about-the-website www.sitename.com/product-news -> www.sitename.com/product-news.php Also another issue I am facing is I can not use any keyword with space. Like "online-products" is fine, but I can't use "online products". Please help me out with your expert knowledge. Many thanks in advance for your kind help. Appreciate it.

    Read the article

  • C# internal VS VBNET Friend

    - by Will Marcouiller
    To this SO question: What is the C# equivalent of friend?, I would personally have answered "internal", just like Ja did among the answers! However, Jon Skeet says that there is no direct equivalence of VB Friend in C#. If Jon Skeet says so, I won't be the one telling otherwise! ;P I'm wondering how can the keyword internal (C#) not be the equivalent of Friend (VBNET) when their respective definitions are: Friend VBNET The Friend (Visual Basic) keyword in the declaration statement specifies that the elements can be accessed from within the same assembly, but not from outside the assembly. [...] internal C# Internal: Access is limited to the current assembly. To my understanding, these definitions mean quite the same to me. Then, respectively, when I'm coding in VB.NET, I use the Friend keyword to specify that a class or a property shall be accessible only within the assembly where it is declared. The same in C#, I use the internal keyword to specify the same. Am I doing something or anything wrong from this perspective? What are the refinements I don't get? Might someone please explain how or in what Friend and internal are not direct equivalences? Thanks in advance for any of your answers!

    Read the article

  • Zend Framework: Zend_DB Error

    - by Sergio E.
    I'm trying to learn ZF, but got strange error after 20 minutes :) Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'Configuration array must have a key for 'dbname' that names the database instance' What does this error mean? I got DB information in my config file: resources.db.adapter=pdo_mysql resources.db.host=localhost resources.db.username=name resources.db.password=pass resources.db.dbname=name Any suggestions? EDIT: This is my model file /app/models/DbTable/Bands.php: class Model_DbTable_Bands extends Zend_Db_Table_Abstract { protected $_name = 'zend_bands'; } Index controller action: public function indexAction() { $albums = new Model_DbTable_Bands(); $this->view->albums = $albums->fetchAll(); } EDIT All codes: bootstrap.php protected function _initAutoload() { $autoloader = new Zend_Application_Module_Autoloader(array( 'namespace' => '', 'basePath' => dirname(__FILE__), )); return $autoloader; } protected function _initDoctype() { $this->bootstrap('view'); $view = $this->getResource('view'); $view->doctype('XHTML1_STRICT'); } public static function setupDatabase() { $config = self::$registry->configuration; $db = Zend_Db::factory($config->db); $db->query("SET NAMES 'utf8'"); self::$registry->database = $db; Zend_Db_Table::setDefaultAdapter($db); Zend_Db_Table_Abstract::setDefaultAdapter($db); } IndexController.php class IndexController extends Zend_Controller_Action { public function init() { /* Initialize action controller here */ } public function indexAction() { $albums = new Model_DbTable_Bands(); $this->view->albums = $albums->fetchAll(); } } configs/application.ini, changed database and provided password: [development : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 db.adapter = PDO_MYSQL db.params.host = localhost db.params.username = root db.params.password = pedro db.params.dbname = test models/DbTable/Bands.php class Model_DbTable_Bands extends Zend_Db_Table_Abstract { protected $_name = 'cakephp_bands'; public function getAlbum($id) { $id = (int)$id; $row = $this->fetchRow('id = ' . $id); if (!$row) { throw new Exception("Count not find row $id"); } return $row->toArray(); } }

    Read the article

  • Dynamically adding radio buttons using JQUERY and then hooking up the jquery change event to the gen

    - by Barry
    i am adding collection of radio buttons to my page using jquery below $(document).ready(function() { $("#Search").click(function() { var keyword = $('#keyWord').val(); var EntityType = $("#lstEntityTypes :selected").text(); var postData = { type: EntityType, keyWord: keyword }; // alert(postData.VehicleType); $.post('/EntityLink/GetJsonEntitySearchResults', postData, function(GRdata) { var grid = '<table><tr><td>ID</td><td>Name</td><td></td>'; for (var i = 0; i < GRdata.length; i++) { grid += '<tr><td>'; grid += GRdata[i].ID; grid += '</td><td>'; grid += GRdata[i].EntityName; grid += '</td><td>'; grid += '<input type="radio" name="EntitiesRadio" value="' + GRdata[i].ID + '" />'; grid += '</td></tr>'; } grid += '</table>'; alert(grid); $("#EntitySearchResults").html(grid); $("EntitiesRadio").change(function() { alert($("EntitiesRadio :checked").val()); $("EntityID").val($("EntitiesRadio :checked").val()); alert($("EntityID").val()); $("EntityName").val($("#lstEntityTypes :selected").text()); }); }); }); // }); so when page loads there is not EntitiesRadio name range, so i tried to register the entitiesRadio change function inside the same search click method but it isnt registering. how do i get the change event to fire to update my hidden inputs

    Read the article

  • What should I do if i have a factory method which requires different parameters for different implem

    - by Sam Holder
    I have an interface, IMessage and a class which have several methods for creating different types of message like so: class MessageService { IMessage TypeAMessage(param 1, param 2) IMessage TypeBMessage(param 1, param 2, param 3, param 4) IMessage TypeCMessage(param 1, param 2, param 3) IMessage TypeDMessage(param 1) } I don't want this class to do all the work for creating these messages so it simply delegates to a MessageCreatorFactory which produces an IMessageCreator depending on the type given (an enumeration based on the type of the message TypeA, TypeB, TypeC etc) interface IMessageCreator { IMessage Create(MessageParams params); } So I have 4 implementations of IMessageCreator: TypeAMessageCreator, TypeBMessageCreator, TypeCMessageCreator, TypeDMessageCreator I ok with this except for the fact that because each type requires different parameters I have had to create a MessageParams object which contains 4 properties for the 4 different params, but only some of them are used in each IMessageCreator. Is there an alternative to this? One other thought I had was to have a param array as the parameter in the Create emthod, but this seems even worse as you don't have any idea what the params are. Or to create several overloads of Create in the interface and have some of them throw an exception if they are not suitable for that particular implementation (ie you called a method which needs more params, so you should have called one of the other overloads.) Does this seem ok? Is there a better solution?

    Read the article

  • Using PHP as template language

    - by Kunal
    I wrote up this quick class to do templating via PHP -- I was wondering if this is easily exploitable if I were ever to open up templating to users (not the immediate plan, but thinking down the road). class Template { private $allowed_methods = array( 'if', 'switch', 'foreach', 'for', 'while' ); private function secure_code($template_code) { $php_section_pattern = '/\<\?(.*?)\?\>/'; $php_method_pattern = '/([a-zA-Z0-9_]+)[\s]*\(/'; preg_match_all($php_section_pattern, $template_code, $matches); foreach (array_unique($matches[1]) as $index => $code_chunk) { preg_match_all($php_method_pattern, $code_chunk, $sub_matches); $code_allowed = true; foreach ($sub_matches[1] as $method_name) { if (!in_array($method_name, $this->allowed_methods)) { $code_allowed = false; break; } } if (!$code_allowed) { $template_code = str_replace($matches[0][$index], '', $template_code); } } return $template_code; } public function render($template_code, $params) { extract($params); ob_start(); eval('?>'.$this->secure_code($template_code).'<?php '); $result = ob_get_contents(); ob_end_clean(); return $result; } } Example usage: $template_code = '<?= $title ?><? foreach ($photos as $photo): ?><img src="<?= $photo ?>"><? endforeach ?>'; $params = array('title' => 'My Title', 'photos' => array('img1.jpg', 'img2.jpg')); $template = new Template; echo $template->render($template_code, $params); The idea here is that I'd store the templates (PHP code) in the database, and then run it through the class which uses regular expressions to only allow permitted methods (if, for, etc.). Anyone see an obvious way to exploit this and run arbitrary PHP? If so, I'll probably go the more standard route of a templating language such as Smarty...

    Read the article

  • How do you test a command object in a grails controller integration test?

    - by egervari
    I'm new to grails. How do I test a form command object to make sure that it's working? Here's some setup code in a test. When I try to do it, I get the following exceptions: Error occurred creating command object. org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Error occurred creating command object. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) .... Caused by: groovy.lang.MissingPropertyException: No such property: password for class: project.user.RegistrationForm Possible solutions: password Here is my test case. As you can see, I set "password" on the params map... void testSaveWhenDataIsCorrect() { controller.params.emailAddress = "[email protected]" controller.params.password = "secret" controller.params.confirmPassword = "secret" controller.save() assertEquals "success", redirectArgs.view ... } Here's the controller action, that adds the command object as a closure parameter: def save = { RegistrationForm form -> if(form.hasErrors()) { render view: "create", model: [form: form] } else { def user = new User(form.properties) user.password = form.encryptedPassword if(user.save()) { redirect(action: "success") } else { render view: "create", model: [form: form] } } } Here's the command object itself... and note that it DOES have a "password" field... class RegistrationForm { def springSecurityService String emailAddress String password String confirmPassword String getEncryptedPassword() { springSecurityService.encodePassword(password) } static constraints = { emailAddress(blank: false, email: true) password(blank: false, size:4..10) confirmPassword(blank: false, validator: { password != confirmPassword }) } } I'm totally lost in the non-intuitive way to do controllers... Please help.

    Read the article

  • problems selecting a mutliple select value from database in Rails

    - by Ramy
    From inside of a form_for in rails, I'm inserting multiple select values into the database, like this: <div class="new-partner-form"> <%= form_for [:admin, matching_profile.partner, matching_profile], :html => {:id => "edit_profile", :multipart => true} do |f| %> <%= f.submit "Submit", :class => "hidden" %> <div class="rounded-block quarter-wide radio-group"> <h4>Exclude customers from source:</h4> <%= f.select :source, User.select(:source).group(:source).order(:source).map {|u| [u.source,u.source]}, {:include_blank => false}, {:multiple => true} %> <%= f.error_message_on :source %> </div> I'm then trying to pull the value from the database like this: def does_not_contain_source(matching_profiles) Expression.select(matching_profiles, :source) do |keyword| Rails.logger.info("Keyword is : " + keyword) @customer_source_tokenizer ||= Tokenizer.new(User.select(:source).where("id = ?", self.owner_id).map {|u| u.source}[0]) #User.select("source").where("id = ?", self.owner_id).to_s) @customer_source_tokenizer.divergent?(keyword) end end but getting this: ExpressionErrors: Bad syntax: --- - "" - B - "" this is what the value is in the database but it seems to choke when i access it this way. What's the right way to do this?

    Read the article

  • JoinColumn name not used in sql

    - by Vladimir
    Hi! I have a problem with mapping many-to-one relationship without exact foreign key constraint set in database. I use OpenJPA implementation with MySql database, but the problem is with generated sql scripts for insert and select statements. I have LegalEntity table which contains RootId column (among others). I also have Address table which has LegalEntityId column which is not nullable, and which should contain values referencing LegalEntity's "RootId" column, but without any database constraint (foreign key) set. Address entity is mapped: @Entity @Table(name="address") public class Address implements Serializable { ... @ManyToOne(fetch=FetchType.LAZY, optional=false) @JoinColumn(referencedColumnName="RootId", name="LegalEntityId", nullable=false, insertable=true, updatable=true, table="LegalEntity") public LegalEntity getLegalEntity() { return this.legalEntity; } } SELECT statement (when fetching LegalEntity's addresses) and INSERT statment are generated: SELECT t0.Id, .., t0.LEGALENTITY_ID FROM address t0 WHERE t0.LEGALENTITY_ID = ? ORDER BY t0.Id DESC [params=(int) 2] INSERT INTO address (..., LEGALENTITY_ID) VALUES (..., ?) [params=..., (int) 2] If I omit table attribute from mentioned statements are generated: SELECT t0.Id, ... FROM address t0 INNER JOIN legalentity t1 ON t0.LegalEntityId = t1.RootId WHERE t1.Id = ? ORDER BY t0.Id DESC [params=(int) 2] INSERT INTO address (...) VALUES (...) [params=...] So, LegalEntityId is not included in any of the statements. Is it possible to have relationship based on such referencing (to column other than primary key, without foreign key in database)? Is there something else missing? Thanks in advance.

    Read the article

  • Usage Rails 3.0 beta 3 without ActiveRecord ORM

    - by Anton
    Hi everybody! Just installed Rails 3.0 beta 3 in Windows 7. And started playing with some easy examples class SignupController < ApplicationController def index @user = User.new(params[:user]) if method.post? and @user.save redirect_to :root end end end class User def initialize(params = {}) @email = params[:email] @passw = params[:password] end def save end end <div align="center"> <% form_for :user do |form| %> <%= form.label :email %> <%= form.text_field :email %><br /> <%= form.label :password %> <%= form.text_field :password %><br /> <%= form.submit :Register! %> <% end %> </div> When I go to /signup I'm getting this error ArgumentError in SignupController#index wrong number of arguments(0 for 1) Is there a problem with constructor or what's wrong?Please, need your help!

    Read the article

  • Fix a 404: missing parameters error from a GET request to CherryPy

    - by norabora
    I'm making a webpage using CherryPy for the server-side, HTML, CSS and jQuery on the client-side. I'm also using a mySQL database. I have a working form for users to sign up to the site - create a username and password. I use jQuery to send an AJAX POST request to the CherryPy which queries the database to see if that username exists. If the username exists, alert the user, if it doesn't, add it to the database and alert success. $.post('submit', postdata, function(data) { alert(data); }); Successful jQuery POST. I want to change the form so that instead of checking that the username exists on submit, a GET request is made as on the blur event from the username input. The function gets called, and it goes to the CherryPy, but then I get an error that says: HTTPError: (404, 'Missing parameters: username'). $.get('checkUsername', getdata, function(data) { alert(data); }); Unsuccessful jQuery GET. The CherryPy: @cherrypy.expose def submit(self, **params): cherrypy.response.headers['Content-Type'] = 'application/json' e = sqlalchemy.create_engine('mysql://mysql:pw@localhost/6470') c = e.connect() com1 = "SELECT * FROM `users` WHERE `username` = '" + params["username"] + "'" b = c.execute(com1).fetchall() if not len(b) > 0: com2 = "INSERT INTO `6470`.`users` (`username` ,`password` ,`website` ,`key`) VALUES ('" com2 += params["username"] + "', MD5( '" + params["password"] + "'), '', NULL);" a = c.execute(com2) c.close() return simplejson.dumps("Success!") #login user and send them to home page c.close() return simplejson.dumps("This username is not available.") @cherrypy.expose def checkUsername(self, username): cherrypy.response.headers['Content-Type'] = 'application/json' e = sqlalchemy.create_engine('mysql://mysql:pw@localhost/6470') c = e.connect() command = "SELECT * FROM `users` WHERE `username` = '" + username + "'" a = c.execute(command).fetchall(); c.close() sys.stdout.write(str(a)) return simplejson.dumps("") I can't see any differences between the two so I don't know why the GET request is giving me a problem. Any insight into what I might be doing wrong would be helpful. If you have ideas about the jQuery, CherryPy, config files, anything, I'd really appreciate it.

    Read the article

  • Rails and SWFUpload: Sporadic Failure on Upload and Response Issue

    - by Gimli
    I've got SWFUpload version 2.5 beta 3 attached to my Rails 2.3.2 application and it works great 75% of the time. The other 25%, I get types of failure. The first failure is a failure to upload. The activity starts, but never actually sends the file to the servers. In my JS, when setting breakpoints, it stops between setting the post params and starting the upload (last two lines below): var params = { "authenticity_token": authToken, "photo[name]": $("#photo_name").val(), "photo[description]": $("#photo_description").val(), "photo[post_id]": $("#post_id").val() }; params[keyName] = key; swfu.setPostParams(params); swfu.startUpload(); It just occurred to me that the file might not being queued, but I've got a handler attached to show the file name in a text box and that works consistently. The second issue is this: Sometimes the response string is truncated. I'm rendering a partial in Rails without a layout to show the uploaded file data in my layout. Most of the time this partial comes through fine, but sometimes it comes through as only the first line, or only parts of the first several lines. The variables seem to be coming through into the view just fine. Any ideas? Thanks!

    Read the article

  • Java and Jasper

    - by bhargava
    Hey Guys, I have integrated Jasper Reports on my netbeans platform and i am able to generate reports using the following code. Map<String, Object> params = new HashMap<String, Object>(); Connection conn = DriverManager.getConnection("databaseUrl", "userid","password"); JasperReport jasperReport = JasperCompileManager.compileReport(reportSource); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, conn); JasperExportManager.exportReportToHtmlFile(jasperPrint, reportDest); JasperViewer.viewReport(jasperPrint); This stuff works perfect. But not i am trying to integrate Jasper with GWT.I have my server as glass fish server. I am getting the Connection object using the followind code. public static Connection getConnection() { try { String JNDI = "JNDI name"; InitialContext initCtx = new InitialContext(); javax.sql.DataSource ds = (javax.sql.DataSource) initCtx.lookup(JNDI); Connection conn = (Connection) ds.getConnection(); return conn; } catch (Exception ex) { ex.printStackTrace(); } return null; } and then Map params = new HashMap(); JasperReport jasperReport = JasperCompileManager.compileReport(reportSource); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, getConnection()); JasperExportManager.exportReportToHtmlFile(jasperPrint, reportDest); JasperViewer.viewReport(jasperPrint); but i always get Error.I am implementing this on Server.I am having RPC calls to get this method to work when a button is clicked. Can you please help me how to work on this.(That is to integrate Jasper reports with GWT). I would highly appreciate any explanation with some code as i am just a beginner. Thanks

    Read the article

  • Address family not supported by protocol exception

    - by srg
    I'm trying to send a couple of values from an android application to a web service which I've setup. I'm using Http Post to send them but when I run the application I get the error- request time failed java.net.SocketException: Address family not supported by protocol. I get this while debugging with both the emulator as well as a device connected by wifi. I've already added the internet permission using: <uses-permission android:name="android.permission.INTERNET" /> This is the code i'm using to send the values void insertData(String name, String number) throws Exception { String url = "http://192.168.0.12:8000/testapp/default/call/run/insertdbdata/"; HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost(url); try { List<NameValuePair> params = new ArrayList<NameValuePair>(2); params.add(new BasicNameValuePair("a", name)); params.add(new BasicNameValuePair("b", number)); post.setEntity(new UrlEncodedFormEntity(params)); HttpResponse response = client.execute(post); }catch(Exception e){ e.printStackTrace(); } Also I know that my web service work fine because when I send the values from an html page it works fine - <form name="form1" action="http://192.168.0.12:8000/testapp/default/call/run/insertdbdata/" method="post"> <input type="text" name="a"/> <input type="text" name="b"/> <input type="submit"/> I've seen questions of similar problems but haven't really found a solution. Thanks

    Read the article

  • Scheme: Mysterious void in pattern match.

    - by Schemer
    Hi. I am writing a function called annotate that uses match-lambda -- often with recursive calls to annotate. Here is one of the pattern matches: (`(lambda (,<param1> . ,<params>) ,<stmts>) `(CLOSURE ENV (,<param1> . ,<params>) (lambda (ENV) ,(map annotate (map (lambda (x) (append `(,<param1> . ,<params>) (list x))) `(,<stmts>)))))) However, when this pattern is matched this is what returns: '(CLOSURE ENV (x) (lambda (ENV) ((CLOSURE ENV (x y) (lambda (ENV) ((+ x y)))))) #<void>) Specifically I can't figure out where "void" is coming from. In fact, if I include the line: ,(displayln (map annotate (map (lambda (x) (append `(,<param1> . ,<params>) (list x))) `(,<stmts>)))) it prints: ((CLOSURE ENV (x y) (lambda (ENV) ((+ x y))))) notably without "void". If someone could tell me what the problem is it would be greatly appreciated. Thanks.

    Read the article

  • How to use the textbox value to fetch the records and to display it in the same page

    - by Aruna
    Hi, i am having a Form like <script language="javascript" type="text/javascript"> function formfn() { var str = document.getElementById('TitleSearch').value; alert(str);//displays the keyword like database } </script> <form name="f1" method="post"> <p><label for="TitleSearch">Keywords:</label> <input title="Keyword" size="40" value="" id="TitleSearch"></p> <p> <input type="submit" id="im-search" value="Search" name="im-search" onClick="formfn();"></p> </form> I am having a page where in the top i have this form on search it has to take the value of the textbox TitleSearch and to use this to retrieve the records matching by <?php $db =& JFactory::getDBO(); $query = 'SELECT * from #__chronoforms_Publications where keyword like "%valueretrieved%" '; $db->setQuery($query); $rows = $db->loadObjectList(); //echo $rows; ?> Once the search button is clicked the text box value of the keyword is retrieved . I am trying to use this value in the select query to fetch the records and to display in the same page.. How to do so..

    Read the article

  • How do I Order on common attribute of two models in the DB?

    - by Will
    If i have two tables Books, CDs with corresponding models. I want to display to the user a list of books and CDs. I also want to be able to sort this list on common attributes (release date, genre, price, etc.). I also have basic filtering on the common attributes. The list will be large so I will be using pagination in manage the load. items = [] items << CD.all(:limit => 20, :page => params[:page], :order => "genre ASC") items << Book.all(:limit => 20, :page => params[:page], :order => "genre ASC") re_sort(items,"genre ASC") Right now I am doing two queries concatenating them and then sorting them. This is very inefficient. Also this breaks down when I use paging and filtering. If I am on page 2 of how do I know what page of each table individual table I am really on? There is no way to determine this information without getting all items from each table. I have though that if I create a new Class called items that has a one to one relationship with either a Book or CD and do something like Item.all(:limit => 20, :page => params[:page], :include => [:books, :cds], :order => "genre ASC") However this gives back an ambiguous error. So can only be refined as Item.all(:limit => 20, :page => params[:page], :include => [:books, :cds], :order => "books.genre ASC") And does not interleave the books and CDs in a way that I want. Any suggestions.

    Read the article

  • in Rails, with check_box_tag, how do I keep the checkboxes checked after submitting query?

    - by Sebastien Paquet
    Ok, I know this is for the Saas course and people have been asking questions related to that as well but i've spent a lot of time trying and reading and I'm stuck. First of all, When you have a model called Movie, is it better to use Ratings as a model and associate them or just keep Ratings in an array floating in space(!). Second, here's what I have now in my controller: def index @movies = Movie.where(params[:ratings].present? ? {:rating => (params[:ratings].keys)} : {}).order(params[:sort]) @sort = params[:sort] @ratings = Ratings.all end Now, I decided to create a Ratings model since I thought It would be better. Here's my view: = form_tag movies_path, :method => :get do Include: - @ratings.each do |rating| = rating.rating = check_box_tag "ratings[#{rating.rating}]" = submit_tag "Refresh" I tried everything that is related to using a conditional ternary inside the checkbox tag ending with " .include?(rating) ? true : "" I tried everything that's supposed to work but it doesn't. I don't want the exact answer, I just need guidance.Thanks in advance!

    Read the article

  • Can anyone help why my mockery doesn't work?

    - by user509550
    The test call real method(service) without mocking some expecations @Test public void testPropertyList() { Credentials creds = new Credentials(); creds.setUsername("someEmail"); creds.setPassword("somePassword"); creds.setReferrer("someReferrer"); final Collection<PropertyInfo> propertyInfoCollection = new LinkedList<PropertyInfo>(); final List<ListingInfo> listings = new ArrayList<ListingInfo>(); listings.add(listingInfoMock); listings.add(listingInfoMock); propertyInfoCollection.add(new PropertyInfo("c521bf5796274bd587c00bec80583c00", listings)); MultivaluedMap<String, String> params = new MultivaluedMapImpl(); params.add("page", "5"); params.add("size", "5"); instance.setPropertyListFacade(propertyListFacadeMock); mockery.checking(new Expectations() { { one(propertyListFacadeMock).getUserProperties(); will(returnValue(propertyInfoCollection)); one(listingInfoMock).getPropertyName(); allowing(listingInfoMock).getThumbnailURL(); one(listingInfoMock).getListingSystemId(); one(listingInfoMock).getPropertyURL(); one(listingInfoMock).getListingSystemId(); one(listingInfoMock).getPropertyURL(); } }); instance.setSessionManager(dashboardSessionManagerMock); testSuccessfulAuthenticate(); ClientResponse response = resource.path(PROPERTIES_PATH).queryParams(params).accept(MediaType.APPLICATION_XML) .get(ClientResponse.class); assertEquals(200, response.getStatus()); mockery.assertIsSatisfied(); }

    Read the article

  • How to order search results by multiple fields?

    - by JustinRoR
    I am using Sunspot and Will_paginate for search in my application and don't how to have my search results start out with certain ordering conditions. The model I am searching is the UserPrice model and want my :price and :purchase_date in descending order or lowest price to highest and present date to past: class UserPrice < ActiveRecord::Base attr_accessible :price, :product_name, :purchase_date belongs_to :product # Sunspot configuration searchable do text :product_name do product.name end end end class SearchController < ApplicationController def index @search = UserPrice.search do fulltext params[:search] paginate(:per_page => 5, :page => params[:page]) end @user_prices = @search.results end end Even though I don't know how, I'm not sure if I would use Sunspot or Will_paginate to sort by order of price and purchase date. How would I achieve this though? Thank you. UPDATE I try to use the order_by method but not sure how the model would look now. class SearchController < ApplicationController def index @search = UserPrice.search do fulltext params[:search] paginate(:per_page => 5, :page => params[:page]) facet(:business_retail_store_id) facet(:business_online_store_id) order_by :price, :desc order_by :purchase_date, :desc end @user_prices = @search.results end end Not sure why having the following in my controller: order_by :price, :desc order_by :purchase_date, :desc I get the error: Sunspot::UnrecognizedFieldError in SearchController#index No field configured for UserPrice with name 'price' This doesn't make sense to me since I do have these fields inside of my UserPrice model and in my database. How do I fix this?

    Read the article

  • Unit testing a method with many possible outcomes

    - by Cthulhu
    I've built a simple~ish method that constructs an URL out of approximately 5 parts: base address, port, path, 'action', and a set of parameters. Out of these, only the address part is mandatory, the other parts are all optional. A valid URL has to come out of the method for each permutation of input parameters, such as: address address port address port path address path address action address path action address port action address port path action address action params address path action params address port action params address port path action params andsoforth. The basic approach for this is to write one unit test for each of these possible outcomes, each unit test passing the address and any of the optional parameters to the method, and testing the outcome against the expected output. However, I wonder, is there a Better (tm) way to handle a case like this? Are there any (good) unit test patterns for this? (rant) I only now realize that I've learned to write unit tests a few years ago, but never really (feel like) I've advanced in the area, and that every unit test is a repeat of building parameters, expected outcome, filling mock objects, calling a method and testing the outcome against the expected outcome. I'm pretty sure this is the way to go in unit testing, but it gets kinda tedious, yanno. Advice on that matter is always welcome. (/rant) (note) christmas weekend approaching, probably won't reply to suggestions until next week. (/note)

    Read the article

  • Usage Rails 3.0 beta 3 without ActiveRecoord ORM

    - by Anton
    Hi everybody! Just installed Rails 3.0 beta 3 in Windows 7. And started playing with some easy examples class SignupController < ApplicationController def index @user = User.new(params[:user]) if method.post? and @user.save redirect_to :root end end end class User def initialize(params = {}) @email = params[:email] @passw = params[:passw] end def save end end <div align="center"> <% form_for :user do |form| %> <%= form.label :email %> <%= form.text_field :email %><br /> <%= form.label :password %> <%= form.text_field :password %><br /> <%= form.submit :Register! %> <% end %> </div> When I go to /signup I'm getting this error NoMethodError in SignupController#index You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.[] Is there a problem with constructor or what's wrong?Please, need your help!

    Read the article

< Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >