bibiki 18 Posting Whiz

Seems like the issue was a Laravel framework specific one.
I had to invoke the toArray() method on my collection of objects before putting it on my return array.

The proper way to do it is:

public function getMembers(){
    $members = Members:all()->toArray();
    $rez = array();
    $rez['aaData'] = $members;
    return $rez;
}

I'm putting the solution up lest someone needs it in the future.

bibiki 18 Posting Whiz

Hi there,
I am having difficulties with integrating datatables. Somehow, my data is being lost/weirdly modified when putting it in my response variable.

foreach($aaData as $aData)
    echo "-".$aData."<br>";
foreach($aaData as $aData)
    $response['aaData'][] = $aData;

My first foreach loop outputs data, and what I see is what I expect.
However, when viewing my data in response, it does not contain the rows of data I expect. It does contain the same number of rows, but only one of my columns, and an additional four fields that I think describe my database table.
In the following, the first is my actual r,ow in database and what I see from my first loop. The second is what my json seems to contain.

-{"id":42,"emri":"Bibiki","mbiemri":"Bibiki","datelindja":"27\/03\/1981","num_personal":"1036","grupi_gjakut":"0","adresa":"","gjinia":"","profesioni":"","telefoni":"","dega":"","nendega":"","statusi_martesor":"0","e_mail":"","data_anetaresimit":"2014-03-12 00:00:00","kombesia":"Shqiptar","admini":1,"vendi_punes":""}

[{"timestamps":false,"gjinia":"Femer","incrementing":true,"exists":true}]

Anyone, please help.
Kind regards

bibiki 18 Posting Whiz

hi guys,
gabrielcastillo's idea sounds good for consistency... this way, on resubmition, my filter will receive the same input as in the first submition, so my app won't behave differently.
so, consistency issues in app behavior are out of the way now. thanks... I did not think of that :)

bibiki 18 Posting Whiz

hi cereal, thanks for your reply.
I am trying to take control of html purification in server side as I am building a whitelist of tags that I want to allow in. As is right now, the encoding of < and > actually prevents AntiSamy to do its job to remove html xss attacks. Any JS attacks are being thwarted allthough the first submition of data allows javascript tags in, but it wrapps their content in [[CDATA... upon the second resubmition, they are removed completely.

Now, letting code in via code tool of tinymce makes things work fine, but using the textarea that first appears to input html tags causes the issue you documented aboe.

I am trying to see what classes the code tool has different than the first textarea and fix the issue... or maybe, I could add an onSubmit listener to my form, to read the content from my first textarea instead of submitting the encoded content of the textarea (sounds confusing because it is).

what do you think?

bibiki 18 Posting Whiz

Hey cereal,
thanks for your reply. I looked in that link, but I am not sure that solves my issue.
What I am having difficulties with is preventin tinyMCE from encoding < and >. However, if you look here http://www.tinymce.com/wiki.php/Configuration:entities you'll see that < and > will ALWAYS be encoded... even if I use the entity_encoding : "raw" option http://www.tinymce.com/wiki.php/Configuration:entity_encoding

perhaps I will have to encode &gt; to > in some filter or something for my code to work. OR, use tinyMCE plugins/toolbars to insert html tags instead of typing them in.
what do you think?

bibiki 18 Posting Whiz

Hi guys,
I am using tinyMCE editor. In my textarea, I want to let user type some html like <table></table> and store that in db just like that, <table></table>.
However, what I am getting is:
&lt;table&gt;&lt;/table&gt;
Now, if I go to the edit form for the item that contains that html piece and I update it, what I get in my database is <table></table>.
Can someone please explain how I can store <table> as <table> in one single step?

bibiki 18 Posting Whiz

hey there,
your base case is more than selectedWith == 0. Like what if selectedWith is not zero, but your current author has no co authors? Then, why are you passing around scholarNeighborhood? Sounds like scholarNeighborhood will hold the result. You can certainly pass it around and be within the definition of a recursive method, but that is for the iterative form of recursion not the linear form (ignore this, unless you already know the difference). what you need is the the linear form recursion, I believe. for that, you need to remove the third input param in your method.
from my understanding, you need to fix your base case, remove your third parameter, and make sure you add ALL co authors of the author that selectedWidth allows for, and if selectedWith is not zero, add all coauthors of all coauthors... I hope you can make sense of what I am saying.

bibiki 18 Posting Whiz

hey masijade, thanks for your reply. I did mvn dependency:build-classpath and it downloaded some artifacts and output the apsolute path to my project's dependencies. But I am not sure that clarified things for me.

What I am trying to figure out is: when I type classpath:fileName in an xml file, where does it look for file fileName? Only src/main/resources in the current project, or in anyother location inside current project? as I described in my question above, context.xml in project A contains classpath:otherFile, but otherFile is not inside project A, it is inside project B which is made use of by A. this is confusing me.

bibiki 18 Posting Whiz

hey there,
I am looking at a maven project that makes use of another maven project. say project A and project B.

In context.xml in project A, I see these two lines

<value>classpath:oneFile</value>

<value>classpath:otherFile</value>

I have been trying to figure out what is the actual value of classpath, so what I did is looked for where inside project A oneFile is located and deduced that the rest of the path to oneFile is what classpath holds. However, that location, that is src/main/resources does not seem to hold the otherFile. Instead, the otherFile is in src/main/resources of project B. My guess right now is that <value>classpath:otherFile</value> is of no use in project A, so it can safely be removed. However, I am not so interested to move that line as I am interested to know what is the actual value of classpath, or is there any way I can find that out. perhaps .classpath file can make that clear for me. I will look at that, but someone with experience please elaborate.

Thanks in advance.

bibiki 18 Posting Whiz

I am not sure that I can help you much about reporting, but I think you should use Derby for database. It's easy to make use of, and as of Java, I think 7, it ships along with Java SDK. it is an embedded DB like sqlite, but is easier to work with. Last time I tried, I gave up on SQLite, and made use of Derby.

bibiki 18 Posting Whiz

sepp2k, thansk for your elaboration. I certainly agree with most of what you say and find interesting your explanations. I failed to declare all of my assumptions when I said "If ++ was a method, and num an object, the num = num++; would have behaved the way Tokamak and I would expect it to." and I see how that raised questions that your MyInt class answered. Anyways, thanks for your input.

bibiki 18 Posting Whiz

hey JamesCherrill, thanks for your patience. I really appreciate it. I understand that part

the value of the expression is the value before the new value is stored,

and am also aware that ++num increments num first, and then does the rest of operations.
Anyways, I'll look at JLS, although I think I got it clearer now.

kind regards.
P.S. Thanks for the protected-less protected topic. I now have something to research about.

bibiki 18 Posting Whiz

Hey JamesCherrill, I still am confused. rather than:

int valueOfExpression = num;
num = num + 1;

I thought, what actually happnes is:

    int num = 0;
    //when we write num = num++;, what I think happens is:
    int valueOfExpression = num;
    num = num;
    valueOfExpression = num + 1;
    //and this leaves num 0, instead of incrementing it to 1.

stultuske, you're right, there is no reason for any emotional reaction on my part for Java's contradiction to my expectations. And, one of the reasons I like being a programmer is that there is no room for arguing with the compiler. But there is nothing wrong with saying Java si wrong either man. Alright, take care.

bibiki 18 Posting Whiz

I have encountered this same issue once, and I happened to have access to someone that other people told me is a guru at the time. And I do take that guy for a guru, but this exact question puzzled him also, so all you much respected Java Forum helpers are a little wrong with your reactions to Tokamak, let me tell you straight forward.

Anyways, this is how the guy I mentioned went about the issue:
he used javap to see the assembly equivalent of the code (correct me if I am wrong with the interpretation of what he did), and tried to see what is actually going on.

Now, with all that specs referencing going on, what the conversation seems to have made necessary is to discuss how the specs are actually implemented.

I do agree with Tokamak that the c++ example he mentioned is closer to how my intuition expects the code to work than Java. I know that the question is solved, but I just wanted to put in my two cents.

AND, as someone that has been paid 12 salaries as a programmer (that is my experience), but is very interested to make sense of ins and outs of programming, here is how I'd speculate and try to make sense of this issue:

Java is very rigid in discerning between Objects and primitive types. If ++ was a method, and num an object, the num = num++; would have behaved the way Tokamak and …

bibiki 18 Posting Whiz

hey peter+budo, sorry for this late reply. note, I changed my artifactId here from the original one. otherwise, the pom is completely the as is in my project.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mynew.app</groupId>
    <artifactId>MyNewApp</artifactId>
    <packaging>war</packaging>
    <version>0.9</version>
    <name>MyNewApp Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <!-- Shared version number properties -->
    <properties>
        <org.springframework.version>3.2.3.RELEASE</org.springframework.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.2.3.Final</version>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.2.2</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
            <version>3.1.3.GA</version>
        </dependency>
        <dependency>
            <groupId>dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <version>1.6.1</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>MyNewApp</finalName>
    </build>
</project>
bibiki 18 Posting Whiz

hey there,
in a project I am involved, someone put a test class in main code. eclipse would not find the bug but mvn, not that in eclipse, would report a compile error, and we found the bug.

because of that, I wanted to build my new maven project without configuring it as a maven project in eclipse. I have been trying to run my skeleton app on tomcat two days and it refused to do so. only when I gave up and converted it to maven did I find that there was nothing wrong with my code, but Tomcat/Eclipse for some reason fails to run my app because it is not eclipse maven plugin enabled.

My question is how do I go about finding out what is happening? what is maven plugin doing? any suggestions are welcome. thanks in advance.

bibiki 18 Posting Whiz

hey JamesCherrill, thanks a lot for your code. I'll look at it closely. It is very much appreciated.

bibiki 18 Posting Whiz

thanks JamesCherrill. I am enthusiastically looking forward to it.

bibiki 18 Posting Whiz

...however, I would love to see the code JamesCherrill. Not only because it is code that I would like to make use of, but also to see your code as I am sure I'd learn something since I have been getting quite some help from you last 3 years. thanks in advance.

bibiki 18 Posting Whiz

yeah, thanks iamthwee. I have created jar files before, and it was quite straight forward. but this one puzzled me. I guess I'll try eclipse's utility for jar generation. thanks again.

bibiki 18 Posting Whiz

I have never used the IDE for this and it slipped my mind that it even is possible.

bibiki 18 Posting Whiz

Ok, I am trying to build a jar file and I cannot seem to find my way around. I have attached an image to this thread to show my directory structure.

Now, I am navigating to my MultiProjectManagement directory and creating my manifest.txt file with:

echo Main-Class: multi.project.management.panels.ProjectListPanel > manifest.txt

Then, I am doing this:
jar -cvfm MPManagement.jar manifest.txt bin multiProjectManagement lib

The jar file is being generated, but when I java -jar MPManagement.jar, I get an error saying:
could not find or load main class: multi.project.management.panels.ProjectListPanel

I understand that my main class is inside bin directory. Now, from what I found online, I hoped that navigating to bin and putting my database, that is multiProjectManagement, and lib folders in bin, and generating the jar file as above would solve the issue, but in that case I am getting a null pointer exception as my program can't find EmbeddedDriver class from derby.jar.

Can someone please guide my how I can create my jar file and make sure it finds my main class, or my EmbeddedDriver class from derby. 0f9c21b88c403301c00e1b0f748fd4ac

bibiki 18 Posting Whiz

hey there, I am working on this project where I need to retreive merchant objects and their corresponding number of failed transactions.

In pure SQL, I'd just write :

"select merchant_id , count(merchant_id) from Transactions where status = 'failed' group by merchant_id"

however, the only way I managed to write the query and have something returned for hql is:

select max(T.merchant), count(T.merchant) from Transaction  T where T.status = 'failed' group by T.merchant

now, max(T.merchant) is where I am afraid I could do better. but without it, I get a "not a group by statement" error. Although my query seems to work well, I am wondering if I can do this better. MAX(T.merchant) is not limiting the number of rows to 1, which is what I want, but contrary to my expectation for how MAX would work. Anyone?
Thanks in advance.

bibiki 18 Posting Whiz

hey Pobunjenik, I am not getting that exception. I complied your code and it compiled and ran with no exception arising. However, you may get that UnsupportedOperationException is for example you try invoking method add() on an array ([]), but you won't get that when you invoke add() on a list. seek for some method invokation in an object that does not support that method inside your code, although I doubt you'll find that in the code you have posted above.

bibiki 18 Posting Whiz

hey Pobunjenik, sta ima? Alright, I am not sure I understand exactly what it is you are having problems with, but I think I found another bug in your code. This method:

public Player addPlayer(String soldierName) {
    this.allPlayers = new ArrayList<>();
    Player P = new Player();
    P.setName(this.name + soldierName);
    allPlayers.add(P);
    return P;
}

initializes your allPlayers list everytime it is invoked. Therefore, at any time it only has one player - not more.

Pobunjenik commented: Evo ništa, vježbam kod malo. :D +2
bibiki 18 Posting Whiz

thank you guys very much. I now think I have a better idea of what Builder pattern is useful for. Thank you again.

bibiki 18 Posting Whiz

hey bguild,
no, build method is not a static one. I was just trying to indicate that it is inside Builder. Sorry for the confusion. thanks for your answer. My understanding is that you say that I use a Builder inner class so that I do not have to write setter methods in my User class, and thus make User immposible to change state? Correct? But then, is there any downside to returning User from its setter methods instead of void if I decide to use them (other than making User possible to change state)? My previous assumption was that I only use Builder pattern so that I make possible setter method chaining.

bibiki 18 Posting Whiz

hey jacksonbird03, please see the two topmost threads in this java forum for projects for java beginners and resources to start java, first and second threads correspondingly.

bibiki 18 Posting Whiz

Hey there, I have a question regarding the builder pattern that I need someone with more experience to clarify for me.

I have this User class that has an inner, public static Builder class that has the same fields as User as well as the corresponding setter methods. Now, the setter methods inside the Builder class return this (the builder instance), and after everything is set, the instance of the builder is passed to Builder.build(this) method that returns a User instance with the fields.

My question is that I can make User setter methods to return this (User object) and render the inner Builder class unnecessary. However, since it is there, I assume there might be some reason why it is so. Anybody any suggestion as to why is one way better than the other?

Thanks in advance.

bibiki 18 Posting Whiz

the computer it is working on has java version 1.7.0_09, the one it is not working on has java version 1.7.0_21 (and it had earlier _17 - not working also). One thing I find weired though is that robot instantiation via web was impossible in 2008 (judging by the dates of forum posts I read online) and it is possible with java version 1.7.0_09. that sounds like a security downgrade. I do not know what this exactly means. Anyways, hope someone has an answer.