Monday, 2 September 2013

jQuery not working, help me solve the error

jQuery not working, help me solve the error

I recently posted a question about some jQuery code (The other post), but
that didn't work and I can't find the problem, please check:
[http://jsfiddle.net/Qqe89/][2]. You'll neeed to read the other post to
understand this problem...

Liferay error adding portlet from Control panel

Liferay error adding portlet from Control panel

If I try to add my custom portlet with "add" button from control panel in
liferay 6.1.1 ga2, I see this error in the console: TypeError:
portletBound is null in the portlet.js file.
If if run the debugger, I see that var portletBound is NULL:
var addPortletReturn = function(html) {
var container = placeHolder.get('parentNode');
var portletBound = A.Node.create('<div></div>');
portletBound.plug(A.Plugin.ParseContent);
portletBound.setContent(html);
portletBound = portletBound.get('firstChild');
var id = portletBound.attr('id');
var portletId = Util.getPortletId(id);
and than I see only a gif Image and nothing happend. Can anybody help?

filtering results in using containsAllObjectsInArray

filtering results in using containsAllObjectsInArray

I am trying to filter results into a searchDisplayController by searching
objects on parse.com. I can successfully search the objects and display
them using containsString but that is not how I want to search the
objects. I would like to search the objects using
containsAllObjectsInArray. I don't know if I am going about this the
correct way but anyway here's the code that I am trying:
- (void)filterResults:(NSString *)searchTerm {
NSCharacterSet *whitespaces = [NSCharacterSet whitespaceCharacterSet];
NSPredicate *noEmptyStrings = [NSPredicate predicateWithFormat:@"SELF !=
''"];
NSArray *parts = [searchTerm
componentsSeparatedByCharactersInSet:whitespaces];
NSArray *filteredArray = [parts filteredArrayUsingPredicate:noEmptyStrings];
NSLog(@" filteredArray equals %@", filteredArray);
[self.searchResults removeAllObjects];
PFQuery *query = [PFQuery queryWithClassName: @"Items"];
[query whereKeyExists:@"itemName"];
[query whereKeyExists:@"itemDescription"];
[query whereKey:@"itemName" containsAllObjectsInArray:filteredArray];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if(!error){
for (PFObject *object in objects){
NSLog(@"%@", objects);
NSLog(@"%u", objects.count);
}
dispatch_async(dispatch_get_main_queue(), ^{
[self.searchResults removeAllObjects];
[self.searchResults addObjectsFromArray:objects];
[self.searchDisplayController.searchResultsTableView reloadData];
});
} else {
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
}
In my output I am receiving the error: "code = 102; error = "$all only
works on array fields";" I don't understand why this doesn't work as
filtered array is obviously an array and the filtered array is being
produced correctly in output.

How to write a function that might fire, given some probability, say: 0 - 100?

How to write a function that might fire, given some probability, say: 0 -
100?

I need a function with certain probability that it will fire, something like:
function broken_fn ( function () { console.log( Math.random() ); }, 33 ) {
// code...
}
for use in simple online game I'm working on...

Sunday, 1 September 2013

PHP Authenticate user for each page of website

PHP Authenticate user for each page of website

I'm developing a website, where in most of pages user need to log in to
view pages of website. What is the best way to check if user is logged in
or not, and if not redirect it to log-in page.
currently I'm using following code to do that.
if(!isset($_SESSION["username"])) //I set the session when user log in
and destroy when user logout
header("location: login.php");
There are lot of pages and I put this code in every page. It also works well.
I want to know is there any other batter way to do this? Or what I'm doing
is good way? and I don't need to change anything.

Replace DELETE for UPDATE with a trigger on SQLite

Replace DELETE for UPDATE with a trigger on SQLite

Is it possible in SQLite to make an update instead of a delete within a
trigger ? I.e, I got these two tables:
CREATE TABLE author (authorid INTEGER PRIMARY KEY, temporal NUMERIC);
CREATE TABLE comment (id INTEGER PRIMARY KEY, text TEXT, authorid INTEGER,
FOREIGN KEY(authorid) REFERENCES author(authorid));
When a deletion of an author is attempted and there's any comment
referencing that author i want to update the "temporal" field and abort
deletion.
I've tested different approaches with triggers but i have not found a way
to do the two things, make the update and abort the delete. I can abort
the delete (though in this case it's not necessary as it is enforced by
the foreign key constraint) or make the update (though the delete will
remove the record, so the update has no effect)

loadind data to listview in vb.net 2008

loadind data to listview in vb.net 2008

I have two tables 1.[Mobilization]-Primary key is [Fen_Inovoice_No] it is
the forgien key is of [invovoice details] 2.[invovoice details] the
primary keys are [Fen_Inovoice_No],[Item] when I tried to view the data ,
the all data are not loading to listview why is that? { Private Sub
viewItem1(ByVal invoice_no As String)
myConnection = New SqlConnection(connectionstring)
myConnection.Open()
sqlcmd = New SqlCommand("SELECT Item,Quantity,Descrption ,Amount FROM
[invovoice details] where Fen_Inovoice_No='" & invoice_no & "' ",
myConnection)
sqlcmd.ExecuteNonQuery()
' Dim dr As SqlDataReader = myCommand1.ExecuteReader
Dim dr As SqlDataReader = sqlcmd.ExecuteReader
dr.Read()
' pr = dr1("Category").ToString
''''''''''''''''''''''''
' For i = 0 To TempData.Rows.Count-1
Dim newItem1 As New ListViewItem(dr.Item("Item").ToString)
newItem1.SubItems.Add(dr("Descrption").ToString)
newItem1.SubItems.Add(dr("Quantity"))
newItem1.SubItems.Add(dr("Amount"))
ListView1.Items.Add(newItem1)
' newItem.SubItems.Add()
CalTotal()
dr.Close()
'''''''''''''''''''''''''''''
myConnection.Close()
End Sub
'''''''''''''''''''''''''''''''''' Private Sub CalTotal() Dim TotalSum As
Double = 0 Dim TempNode As ListViewItem Dim TempDbl As Double For Each
TempNode In ListView1.Items If
Double.TryParse(TempNode.SubItems.Item(3).Text, TempDbl) Then
End If
TotalSum += TempDbl
Next
TextBox11.Text = TotalSum
End Sub
}