Search Results

Search found 10634 results on 426 pages for 'pass'.

Page 31/426 | < Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >

  • Pass Result of ASIHTTPRequest "requestFinished" Back to Originating Method

    - by Intelekshual
    I have a method (getAllTeams:) that initiates an HTTP request using the ASIHTTPRequest library. NSURL *httpURL = [[[NSURL alloc] initWithString:@"/api/teams" relativeToURL:webServiceURL] autorelease]; ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:httpURL] autorelease]; [request setDelegate:self]; [request startAsynchronous]; What I'd like to be able to do is call [WebService getAllTeams] and have it return the results in an NSArray. At the moment, getAllTeams doesn't return anything because the HTTP response is evaluated in the requestFinished: method. Ideally I'd want to be able to call [WebService getAllTeams], wait for the response, and dump it into an NSArray. I don't want to create properties because this is disposable class (meaning it doesn't store any values, just retrieves values), and multiple methods are going to be using the same requestFinished (all of them returning an array). I've read up a bit on delegates, and NSNotifications, but I'm not sure if either of them are the best approach. I found this snippet about implementing callbacks by passing a selector as a parameter, but it didn't pan out (since requestFinished fires independently). Any suggestions? I'd appreciate even just to be pointed in the right direction. NSArray *teams = [[WebService alloc] getAllTeams]; (currently doesn't work, because getAllTeams doesn't return anything, but requestFinished does. I want to get the result of requestFinished and pass it back to getAllTeams:)

    Read the article

  • pass object from JS to PHP and back

    - by Radu
    This is something that I don't think can't be done, or can't be done easy. Think of this, You have an button inside a div in HTML, when you click it, you call a php function via AJAX, I would like to send the element that start the click event(or any element as a parameter) to PHP and BACK to JS again, in a way like serialize() in PHP, to be able to restore the element in JS. Let me give you a simple example: PHP: function ajaxCall(element){ return element; } JS: callbackFunction(el){ el.color='red'; } HTML: <div id="id_div"> <input type="button" value="click Me" onClick="ajaxCall(this, callbackFunction);" /> </div> So I thing at 3 methods method 1. I can give each element in the page an ID. so the call to Ajax would look like this: ajaxCall(this.id, callbackFunction); and the callback function would be: document.getElementById(el).color='red'; This method I think is hard, beacause in a big page is hard to keep track of all ID's. method 2. I think that using xPath could be done, If i can get the exact path of an element, and in the callback function evaluate that path to reach the element. This method needs some googling, it is just an ideea. method 3. Modify my AJAX functions, so it retain the element that started the event, and pass it to the callback function as argument when something returns from PHP, so in my AJAX would look like this: eval(callbackFunction(argumentsFromPhp, element)); and the callback function would be: callbackFunction(someArgsFromPhp, el){ el.color='red'; // parse someArgsFromPhp } I think that the third option is my choise to start this experiment. Any of you has a better idea how I can accomplish this ? Thank you.

    Read the article

  • How do I pass parameters between request-scoped beans

    - by smayers81
    This is a question that has been bothering me for sometime. My application uses ICEFaces for our UI framework and Spring 2.5 for Dependency Injection. In addition, Spring actually maintains all of our backing beans, not the ICEFaces framework, so our faces-config is basically empty. Navigation is not even really handled through navigation-rules. We perform manual redirects to new windows using window.open. All of our beans are defined in our appContext file as being request-scoped. I have Page ABC which is backed by BackingBeanABC. Inside that backing bean, I have a parameter say: private Order order; I then have Page XYZ backed by BackingBeanXYZ. When I redirect from page ABC to page XYZ, I want to transfer the 'order' property from ABC to XYZ. The problem is since everything is request-scoped and I'm performing a redirect, I am losing the value of 'description'. There has got to be an easier way to pass objects between beans in request scope during a redirect. Can anyone assist with this issue?

    Read the article

  • Pass the values from ListView control to text boxes in c#

    - by Kumu
    private void deleteDisplayGamesButton_Click(object sender, EventArgs e) { //Game game = new Game(homeTeamComboBox.Text, int.Parse(homeScoreUpDown.Value.ToString()), awayTeamComboBox.Text, int.Parse(awayScoreUpDown.Value.ToString())); deleteDisplayGamesListView.Items.Clear(); deleteDisplayGamesListView.View = View.Details; foreach (Game currentgame in footballLeagueDatabase.games) { ListViewItem row = new ListViewItem(); row.SubItems.Add(currentgame.HomeTeam.ToString()); row.SubItems.Add(currentgame.HomeScore.ToString()); row.SubItems.Add(currentgame.AwayTeam.ToString()); row.SubItems.Add(currentgame.AwayScore.ToString()); deleteDisplayGamesListView.Items.Add(row); } } I need to pass the values from above ListView control to following text boxes when I use the deleteDisplayGamesListView_SelectedIndexChanged method. private void deleteDisplayGamesListView_SelectedIndexChanged(object sender, EventArgs e) { deleteModifyHomeTeamTxt.Text = ""; deleteModifyHomeScoreUpDown.Text = ""; deleteModifyAwayTeamTxt.Text = ""; deleteModifyAwayScoreUpDown.Text = ""; foreach (Game currentgame in footballLeagueDatabase.games); { ?----------------------------- } } Futhermore I need to clear this data from the ListView Control. If you know how to do this please let me know.

    Read the article

  • pass a number value to a Timer, XML and AS3

    - by VideoDnd
    I want to pass a number value to a Timer. How do I do this? My number and integer values for other variables work fine. Error I get null object reference and coercion of value, because I'm not passing to 'timer' properly. I don't want to say my variable's a number, I want to say it has a number value. Variable //what I have now var timer:Timer; timer = new Timer(100); Path myXML.COUNT.text(); XML <?xml version="1.0" encoding="utf-8"?> <SESSION> <TIMER TITLE="speed">100</TIMER> </SESSION> Parse and Load //LOAD XML var myXML:XML; var myLoader:URLLoader = new URLLoader(); myLoader.load(new URLRequest("time.xml")); myLoader.addEventListener(Event.COMPLETE, processXML); //PARSE XML function processXML(e:Event):void { myXML = new XML(e.target.data);

    Read the article

  • pass other form elements to ajax suggestion box script

    - by Alex Calder
    I paid somebody to build me a jQuery AJAX suggestion box script a while back. It works great. Now I'm trying to learn about it enough to modify it to do something different. Right now, the script that generates the suggestions just takes the query text and does the same check every time. Now, I want to be able to pass along additional info so different things are looked for with each instance of a search box. The HTML... simple, obvious. input class="suggest" name="q" type="text" autocomplete="off" / The jQuery looks like this: jQuery(document).ready(function() { $('.suggest').autocomplete( { source:'output.php', minLength:3, focus: function (event, ui) { $(event.target).val(ui.item.label); return false; } } ); [snip] } Instead of: source:'output.php', minLength:3, I'd like: source:'output.php?arg1=blah1&arg2=blah2', minLength:3, where arg1 and arg2 are passed along in the form... input class="suggest" name="q" type="text" autocomplete="off" / input type="hidden" name="arg1" value="blah1" input type="hidden" name="arg2" value="blah2" Does this make sense? Thanks guys. I know just about "this much" about OOL's and javascript, so I'm learning... Alex

    Read the article

  • jquery pass value class

    - by mckenzie
    $(".hidee2").click(function() { var type = $(".st").val(); } <form action="" method="POST"><input type="hidden" class="st" value="st"><div class="button">Room Status : Accepting Reservation <br /><span><span><a class="hidee2">Book Now!</a></span></span></div></form> <form action="" method="POST"><input type="hidden" class="st" value="st2"><div class="button">Room Status : Accepting Reservation <br /><span><span><a class="hidee2">Book Now!</a></span></span></div></form> <form action="" method="POST"><input type="hidden" class="st" value="st3"><div class="button">Room Status : Accepting Reservation <br /><span><span><a class="hidee2">Book Now!</a></span></span></div></form> How do i get which book now! link user click? because i need to pass over the st value? is there any way to achieve this using jquery? currently, only st value is passed over

    Read the article

  • Android Compass orientation on unreliable (Low pass filter)

    - by madsleejensen
    Hi all Im creating an application where i need to position a ImageView depending on the Orientation of the device. I use the values from a MagneticField and Accelerometer Sensors to calculate the device orientation with SensorManager.getRotationMatrix(rotationMatrix, null, accelerometerValues, magneticFieldValues) SensorManager.getOrientation(rotationMatrix, values); double degrees = Math.toDegrees(values[0]); My problem is that the positioning of the ImageView is very sensitive to changes in the orientation. Making the imageview constantly jumping around the screen. (because the degrees change) I read that this can be because my device is close to things that can affect the magneticfield readings. But this is not the only reason it seems. I tried downloading some applications and found that the "3D compass" application remains extremely steady in its readings, i would like the same behavior in my application. I read that i can tweak the "noise" of my readings by adding a "Low pass filter", but i have no idea how to implement this (because of my lack of Math). Im hoping someone can help me creating a more steady reading on my device, Where a little movement to the device wont affect the current orientation. Right now i do a small if (Math.abs(lastReadingDegrees - newReadingDegrees) > 1) { updatePosition() } To filter abit of the noise. But its not working very well :)

    Read the article

  • Pass Linq Expression to a function

    - by Kushan Hasithe Fernando
    I want to pass a property list of a class to a function. with in the function based on property list I'm going to generate a query. As exactly same functionality in Linq Select method. Here I'm gonna implement this for Ingress Database. As an example, in front end I wanna run a select as this, My Entity Class is like this public class Customer { [System.Data.Linq.Mapping.ColumnAttribute(Name="Id",IsPrimaryKey=true)] public string Id { get; set; } [System.Data.Linq.Mapping.ColumnAttribute(Name = "Name")] public string Name { get; set; } [System.Data.Linq.Mapping.ColumnAttribute(Name = "Address")] public string Address { get; set; } [System.Data.Linq.Mapping.ColumnAttribute(Name = "Email")] public string Email { get; set; } [System.Data.Linq.Mapping.ColumnAttribute(Name = "Mobile")] public string Mobile { get; set; } } I wanna call a Select function like this, var result = dataAccessService.Select<Customer>(C=>C.Name,C.Address); then,using result I can get the Name and Address properties' values. I think my Select function should looks like this, ( *I think this should done using Linq Expression. But im not sure what are the input parameter and return type. * ) Class DataAccessService { // I'm not sure about this return type and input types, generic types. public TResult Select<TSource,TResult>(Expression<Func<TSource,TResult>> selector) { // Here using the property list, // I can get the ColumnAttribute name value and I can generate a select query. } } This is a attempt to create a functionality like in Linq. But im not an expert in Linq Expressions. There is a project call DbLinq from MIT, but its a big project and still i couldn't grab anything helpful from that. Can someone please help me to start this, or can someone link me some useful resources to read about this.

    Read the article

  • VB .NET error handling, pass error to caller

    - by user1375452
    this is my very first project on vb.net and i am now struggling to migrate a vba working add in to a vb.net COM Add-in. I think i'm sort of getting the hang, but error handling has me stymied. This is a test i've been using to understand the try-catch and how to pass exception to caller Public Sub test() Dim ActWkSh As Excel.Worksheet Dim ActRng As Excel.Range Dim ActCll As Excel.Range Dim sVar01 As String Dim iVar01 As Integer Dim sVar02 As String Dim iVar02 As Integer Dim objVar01 As Object ActWkSh = Me.Application.ActiveSheet ActRng = Me.Application.Selection ActCll = Me.Application.ActiveCell iVar01 = iVar02 = 1 sVar01 = CStr(ActCll.Value) sVar02 = CStr(ActCll.Offset(1, 0).Value) Try objVar01 = GetValuesV(sVar01, sVar02) 'DO SOMETHING HERE Catch ex As Exception MsgBox("ERRORE: " + ex.Message) 'LOG ERROR SOMEWHERE Finally MsgBox("DONE!") End Try End Sub Private Function GetValuesV(ByVal QryStr As Object, ByVal qryConn As String) As Object Dim cnn As Object Dim rs As Object Try cnn = CreateObject("ADODB.Connection") cnn.Open(qryConn) rs = CreateObject("ADODB.recordset") rs = cnn.Execute(QryStr) If rs.EOF = False Then GetValuesV = rs.GetRows Else Throw New System.Exception("Query Return Empty Set") End If Catch ex As Exception Throw ex Finally rs.Close() cnn.Close() End Try End Function i'd like to have the error message up to test, but MsgBox("ERRORE: " + ex.Message) pops out something unexpected (Object variable or With block variable not set) What am i doing wrong here?? Thanks D

    Read the article

  • Pass data from thread into Activity

    - by Laimoncijus
    Hi, I am want to pass data back from a Thread to Activity (which created the thread). So I am doing like described on Android documentation: public class MyActivity extends Activity { [ . . . ] // Need handler for callbacks to the UI thread final Handler mHandler = new Handler(); // Create runnable for posting final Runnable mUpdateResults = new Runnable() { public void run() { updateResultsInUi(); } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); [ . . . ] } protected void startLongRunningOperation() { // Fire off a thread to do some work that we shouldn't do directly in the UI thread Thread t = new Thread() { public void run() { mResults = doSomethingExpensive(); mHandler.post(mUpdateResults); } }; t.start(); } private void updateResultsInUi() { // Back in the UI thread -- update our UI elements based on the data in mResults [ . . . ] } } Only one thing I am missing here - where and how should be defined mResults so I could access it from both Activity and Thread, and also would be able to modify as needed? If I define it as final in MyActivity, I can't change it anymore in Thread - as it is shown in example... Thanks!

    Read the article

  • How to pass common arguments to Perl modules

    - by Leonard
    I'm not thrilled with the argument-passing architecture I'm evolving for the (many) Perl scripts that have been developed for some scripts that call various Hadoop MapReduce jobs. There are currently 8 scripts (of the form run_something.pl) that are run from cron. (And more on the way ... we expect anywhere from 1 to 3 more for every function we add to hadoop.) Each of these have about 6 identical command-line parameters, and a couple command line parameters that are similar, all specified with Euclid. The implementations are in a dozen .pm modules. Some of which are common, and others of which are unique.... Currently I'm passing the args globally to each module ... Inside run_something.pl I have: set_common_args (%ARGV); set_something_args (%ARGV); And inside Something.pm I have sub set_something_args { (%MYARGS) =@_; } So then I can do if ( $MYARGS{'--needs_more_beer'} ) { $beer++; } I'm seeing that I'm probably going to have additional "common" files that I'll want to pass args to, so I'll have three or four set_xxx_args calls at the top of each run_something.pl, and it just doesn't seem too elegant. On the other hand, it beats passing the whole stupid argument array down the call chain, and choosing and passing individual elements down the call chain is (a) too much work (b) error-prone (c) doesn't buy much. In lots of ways what I'm doing is just object-oriented design without the object-oriented language trappings, and it looks uglier without said trappings, but nonetheless ... Anyone have thoughts or ideas?

    Read the article

  • Pass in a value into Python Class through command line

    - by chrissygormley
    Hello, I have got some code to pass in a variable into a script from the command line. The script is: import sys, os def function(var): print var class function_call(object): def __init__(self, sysArgs): try: self.function = None self.args = [] self.modulePath = sysArgs[0] self.moduleDir, tail = os.path.split(self.modulePath) self.moduleName, ext = os.path.splitext(tail) __import__(self.moduleName) self.module = sys.modules[self.moduleName] if len(sysArgs) > 1: self.functionName = sysArgs[1] self.function = self.module.__dict__[self.functionName] self.args = sysArgs[2:] except Exception, e: sys.stderr.write("%s %s\n" % ("PythonCall#__init__", e)) def execute(self): try: if self.function: self.function(*self.args) except Exception, e: sys.stderr.write("%s %s\n" % ("PythonCall#execute", e)) if __name__=="__main__": test = test() function_call(sys.argv).execute() This works by entering ./function <function> <arg1 arg2 ....>. The problem is that I want to to select the function I want that is in a class rather than just a function by itself. The code I have tried is the same except that function(var): is in a class. I was hoping for some ideas on how to modify my function_call class to accept this. Thanks for any help.

    Read the article

  • Get the id of the link and pass it to the jQueryUI dialog widget

    - by Mike Sanchez
    I'm using the dialog widget of jQueryUI. Now, the links are grabbed from an SQL database by using jQuery+AJAX which is the reason why I used "live" $(function() { var $dialog = $('#report') .dialog({ autoOpen: false, resizable: false, modal: true, height: 410, width: 350, draggable: true }) //store reference to placeholders $uid = $('#reportUniqueId'); $('.reportopen').live("click", function (e) { $dialog.dialog('open'); var $uid = $(this).attr('id'); e.preventDefault(); }); }); My question is, how do I pass the id of the link that triggered the dialog widget to the dialog box itself? The link is set up like this: <td align="left" width="12%"> <span id="notes"> [<a href="javascript:void(0)" class="reportopen" id="<?=$reportId;?>">Spam</a>] </span> </td> And the dialogbox is set up like this: <div id="report" title="Inquire now"> HAHAHAHAHA <span id="reportUniqueId"></span> </div> I'd like for the id to be passed and generated in the <span id="reportUniqueId"></span> part of the dialog box. Any idea?

    Read the article

  • How to pass a value from the Jquery validation

    - by user2963960
    How can i pass a value from the jquery validation. I have an input box named clubCardNumber it should validate the length of the inputted value. If the length is equal to 10 the value passes to the hidden field named else validated it if its null or empty if all validations are true then its a clubCard. Here is how i implemented it on Javascript function validateClubCardNumber() { var varClubCardNumber = $('#clubCardNumber').val(); $('#phoneNumber').val(""); var returnVal = true; if ((null == varClubCardNumber || '' == trim(varClubCardNumber)){ return false; } if( varClubCardNumber.length < 10 ){ return false; }else if( varClubCardNumber.length == 10 ) { //The Phone Number field should contains numbers only var pattern = /^[0-9 -]*$/ ; var flag = pattern.test(trim(varClubCardNumber)); if(flag == false){ return false; }else{ $('#phoneNumber').val(varClubCardNumber); returnVal = true; } } } return returnVal; } HTML <div > <label for="clubCardNumber" >Card or Phone Number:</label> <input id="clubCardNumber" name="clubCardNumber" type="text" placeholder="Card or Phone Number" value="" maxlength="20"/> </div> <input type="hidden" id="phoneNumber" name="phoneNumber" value=""/>

    Read the article

  • How to pass value in url using web request GET method asp.net

    - by Narasi
    Am new to .Net and web service..i like to pass id through url..how to do that?whether it was done post or get method?guide me string url = "http://XXXXX//"+id=22; WebRequest request = WebRequest.Create(url); request.Proxy.Credentials = new NetworkCredential(xxxxx); request.Credentials = CredentialCache.DefaultCredentials; //add properties request.Method = "GET"; request.ContentType = "application/json"; //convert byte[] byteArray = Encoding.UTF8.GetBytes(data); request.ContentLength = byteArray.Length; //post data Stream streamdata = request.GetRequestStream(); streamdata.Write(byteArray, 0, byteArray.Length); streamdata.Close(); //response WebResponse response = request.GetResponse(); // Get the stream containing content returned by the server. Stream dataStream = response.GetResponseStream(); // Open the stream using a StreamReader for easy access. StreamReader reader = new StreamReader(dataStream); // Read the content. string responseFromServer = reader.ReadToEnd(); // Clean up the streams and the response. reader.Close(); response.Close(); Thanks in advance

    Read the article

  • Pass view to viewmodel with datatemplate

    - by jpsstavares
    I have a ParameterView and ParameterViewModel, and I need the ParameterViewModel to have a reference to the Parameter view (more on that later). In the window I have a list of ParameterViewModels and in the ResourceDictionary I add the DataTemplate: <DataTemplate DataType="{x:Type my:ParameterViewModel}" > <my:ParameterView HorizontalAlignment="Left"/> </DataTemplate> I then bind an ItemsControl.ItemSource to the List of ParameterViewModels The problem is: How can I pass the ParameterView to the ParameterViewModel in this scenario? The reason I need the ParameterView in the ParameterViewModel is the following: I have a TextBox whose Text property is binded to the PropertyModelView.Name property. But I want to display a default string when the Name is empty or Null. I've tried to set the property value to the default string I want when that happens but the TextBox.Text is not set in this scenario. I do something like this: private string _name; public string Name { get { return _name; } set { if (value == null || value.Length == 0) Name = _defaultName; else _name = value; } } I've also tried to specifically set the TextBox.Text binding mode to TwoWay without success. I think this is a defense mechanism to prevent an infinite loop from happening but I don't know for sure. Any help on this front would also be highly appreciated. Thanks, José Tavares

    Read the article

  • Pass a variable from the source file to an included file in PHP

    - by Alpha1
    For my website I want to store the general format of the site in a single PHP file in a single location, and each of the different pages content in the local location of the page. I then want to pass the title and content address to the included file via a variable. However I can't get the included format file to read the variables storing the title and content data. AKA, the called file for the individual page would be: <?php $title = 'Some Title'; $source_file = 'content.php'; readfile('http:...../format.php'); ?> The format file would be: <html> ... <title> <?php echo $title; ?> </title> ... <?php include($source_file); ?> ... I recall reading somewhere I need to include something to get the variables at the start of the format file, however I can't remember what it is or find where I found that information.

    Read the article

  • How to pass a Lambda Expression as method parameter with EF

    - by Registered User
    How do I pass an EF expression as a method argument? To illustrate my question I have created a pseudo code example: The first example is my method today. The example utilizes EF and a Fancy Retry Logic. What I need to do is to encapsulate the Fancy Retry Logic so that it becomes more generic and does not duplicate. In the second example is how I want it to be, with a helper method that accepts the EF expression as an argument. This would be a trivial thing to do with SQL, but I want to do it with EF so that I can benefit from the strongly typed objects. First Example: public static User GetUser(String userEmail) { using (MyEntities dataModel = new MyEntities ()) { var query = FancyRetryLogic(() => { (dataModel.Users.FirstOrDefault<User>(x => x.UserEmail == userEmail))); }); return query; } } Second Example: T RetryHelper<T>(Expression<Func<T, TValue>> expression) { using (MyEntities dataModel = new (MyEntities ()) { var query = FancyRetryLogic(() => { return dataModel.expression }); } } public User GetUser(String userEmail) { return RetryHelper<User>(<User>.FirstOrDefault<User>(x => x.UserEmail == userEmail)) }

    Read the article

  • PHP Pass Dynamic Array name to function

    - by Brad
    How do I pass an array key to a function to pull up the right key's data? // The array <?php $var['TEST1'] = Array ( 'Description' => 'This is a Description', 'Version' => '1.11', 'fields' => Array( 'ID' => array( 'type' => 'int', 'length' =>'11', 'misc' =>'auto_increment' ), 'DATA' => array( 'type' => 'varchar', ' length' => '255' ) ); $var['TEST2'] = Array ( 'Description' =? 'This is the 2nd Description', 'Version' => '2.1', 'fields' => Array( 'ID' => array( 'type' => 'int', 'length' =>'11', 'misc' =>'auto_increment' ), 'DATA' => array( 'type' => 'varchar', ' length' => '255' ) ) // The function <?php $obj = 'TEST1'; print_r($schema[$obj]); // <-- Fives me output. But calling the function doesn't. echo buildStructure($obj); /** * @TODO to add auto_inc support */ function buildStructure($obj) { $output = ''; $primaryKey = $schema["{$obj}"]['primary key']; foreach ($schema["{$obj}"]['fields'] as $name => $tag) // #### ERROR #### Invalid argument supplied for foreach() { $type = $tag['type']; $length = $tag['length']; $default = $tag['default']; $description = $tag['description']; $length = (isset($length)) ? "({$length})" : ''; $default = ($default == NULL ) ? "NULL" : $default; $output .= "`{$name}` {$type}{$length} DEFAULT {$default} COMMENT `{$DESCRIPTION}`, "; } return $output; }

    Read the article

  • how to pass value to controller??

    - by rajesh
    When I try to pass url value to controller action, action is not getting the required value. I'm sending the value like this: function value(url,id) { alert(url); document.getElementById('rating').innerHTML=id; var params = 'artist='+id; alert(params); // var newurl='http://localhost/songs_full/public/eslresult/ratesong/userid/1/id/27'; var myAjax = new Ajax.Request(newurl,{method: 'post',parameters:params,onComplete: loadResponse}); //var myAjax = new Ajax.Request(url,{method:'POST',parameters:params,onComplete: load}); //alert(myAjax); } function load(http) { alert('success'); } and in the controller I have: public function ratesongAction() { $user=$_POST['rating']; echo $user; $post= $this->getRequest()->getPost(); //echo $post; $ratesongid= $this->_getParam('id'); } But still not getting the result. I am using zend framework.

    Read the article

  • Pass Arguments to Included Module in Ruby?

    - by viatropos
    I'm hoping to implement something like all of the great plugins out there for ruby, so that you can do this: acts_as_commentable has_attached_file :avatar But I have one constraint: That helper method can only include a module; it can't define any variables or methods. The reason for this is because, I want the options hash to define something like type, and that could be converted into one of say 20 different 'workhorse' modules, all of which I could sum up in a line like this: def dynamic_method(options = {}) include ("My::Helpers::#{options[:type].to_s.camelize}").constantize(options) end Then those 'workhorses' would handle the options, doing things like: has_many "#{options[:something]}" Here's what the structure looks like, and I'm wondering if you know the missing piece in the puzzle: # 1 - The workhorse, encapsuling all dynamic variables module My::Module def self.included(base) base.extend ClassMethods base.class_eval do include InstanceMethods end end module InstanceMethods self.instance_eval %Q? def #{options[:my_method]} "world!" end ? end module ClassMethods end end # 2 - all this does is define that helper method module HelperModule def self.included(base) base.extend(ClassMethods) end module ClassMethods def dynamic_method(options = {}) # don't know how to get options through! include My::Module(options) end end end # 3 - send it to active_record ActiveRecord::Base.send(:include, HelperModule) # 4 - what it looks like class TestClass < ActiveRecord::Base dynamic_method :my_method => "hello" end puts TestClass.new.hello #=> "world!" That %Q? I'm not totally sure how to use, but I'm basically just wanting to somehow be able to pass the options hash from that helper method into the workhorse module. Is that possible? That way, the workhorse module could define all sorts of functionality, but I could name the variables whatever I wanted at runtime.

    Read the article

  • WebGL pass array shader

    - by user987058
    I'm new to WebGL and I'm facing some problems of the shaders. I wanna do multiple light sources in the scene. I searched online and knew that in WebGL, you can't pass an array into the fragment shader, so the only way is use the texture. Here is the problem I can't figure out. First, I create a 32x32 texture using the following code: var pix = []; for(var i=0;i<32;i++) { for(var j=0;j<32;j++) pix.push(0.8,0.8,0.1); } gl.activeTexture(gl.TEXTURE0); gl.bindTexture(gl.TEXTURE_2D, lightMap); gl.pixelStorei(gl.UNPACK_ALIGNMENT,1); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 32,32,0, gl.RGB, gl.UNSIGNED_BYTE,new Float32Array(pix)); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); gl.uniform1i(g_loader.program.set_uniform["u_texture2"],0); But however, when I tried to access the texture in the shader: [Fragment Shader] varying vec2 v_texcoord; uniform sampler2D u_texture2; void main(void) { vec3 lightLoc = texture2D(u_texture, v_texcoord).rgb; gl_FragData[0] = vec4(lightLoc,1.0); } The result is totally black. Is there anyone knows how to acces or create the texture correctly?

    Read the article

  • How do I pass a value to a method in Objective C

    - by user268124
    I'm new to Obj-C and I have run in to a very, very basic mental block that's making me feel a little stupid. I want to pass a variable from one method to another in an purely objective-C way. So far I'm stuck and have resorted to writing it in C. In C it goes as follows; //detect the change in the segmented switch so we can; change text - (IBAction)switchChanged:(id)sender { NSLog(@"Switch change detected"); //grab the info from the sender UISegmentedControl *selector = sender; //grab the selected segment info from selector. This returns a 0 or a 1. int selectorIndex = [selector selectedSegmentIndex]; changeText (selectorIndex); } int changeText (int selectorPosition) { NSLog(@"changeText received a value. Selector position is %d", selectorPosition); //Idea is to receive a value from the segmented controler and change the screen text accordingly return 0; } This works perfectly well, but I want to learn how to do this with objects and messages. How would I rewrite these two methods to do this? Cheers Rich

    Read the article

  • Pass List of models to controller ASP.NET MVC 5

    - by user3697231
    I have a view where user can enter some data. But problem is this: Let's say you have 3 text box on view. Every time user can fill multiple times this 3 text boxes. To clarify, let's say user fills this 3 text boxes and press button which adds on form again these 3 text boxes. Now when user clicks submit this form is sent to controller, but how do I sent List of models as parameter. My architecture for this problem is something like this: MyModel public int ID { get;set; } public string Something { get; set; } /*This three textboxes can user set multiple times*/ /*Perhaps i Can create new model with these properties and then /*put List of that model as property here, but how to fill that list inside view ??*/ public string TextBoxOneValue { get; set; } public string TextBoxTwoValue { get; set; } public string TextBoxThreeValue { get; set; } Now, i was thinking that i Create PartialView with this 3 text boxes, and then when user clicks button on view another PartialView is loaded. And now, let's say I have Two partial views loaded, and user clicks submit, how that I pass list with values of these 3 text boxes to controller ??

    Read the article

< Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >