Jozo Stan

Greenhorn
+ Follow
since Aug 18, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Jozo Stan

Hi,

I have an application developed in ggts with grails/groovy and there are users with different roles. I want to test if a user can access some parts of the application by directly inserting link into address bar. So, where is my problem? When I test my application on localhost, everything is OK. But when I want to test through http://myapp then it isn't OK. The application is the same.

Here is my code:

LoginSpec.groovy




ProductPage.groovy



config.grails.serverURL should be http://myapp.


When I start the test, it opens http://myapp/login, the user logs in and the home page opens. But then it stays on home page. It should go to http://myapp/shop/catalog/show/123 because I want to test if a user can access a product by directly inserting a link into address bar.

Please help, I don't have any more ideas.
Thanks.
11 years ago
Hello everyone!


I have a database table with sport matches. In my application users can choose which matches they want to follow by clicking on add in a data-tables table. I fetch matches from database with this method:




With that method I achieve that only new matches are shown to the user. Finished matches remain in database. For example, if there are 10 matches. 4 are finished. Number of matches is still 10 but I fetch in my list only 6. When user wants to add a match with ID >=6, application crashes and the java.lang.IndexOutOfBoundsException appears. If I remove the WHERE part of query, then I don't receive this exception.


Here is my code:

Controller index.java




How could I solve this exception?

Thanks.
Jozo


12 years ago
I have finally solved this. Thank you all!

Here is my code:

Method from HibernateDAO





Controller





Part of jsp

12 years ago
JSP
I have a sport database with country, sport, team and match tables. I'm developing a web application in Spring where users could discuss about match results, view statistics and so on.
Well, I'm stuck with head2head statistics. I have two dropdown boxes with teams. User selects host and guest. When he clicks on show, controller should fetch all the matches where the selected teams have played against each other. The results should display on the same page. Unfortunately, this isn't happening.

Here is my code.

Fetch method in HibernateDAO domacin = host, gost = guest





H2Hstat.java




h2Hstat.jsp




Is this actually possible to achieve on the same page? When I submit the form I get empty table.

Please help.
12 years ago
Thank you very much! I solved that issue. I couldn't post before because I still have other problems with my application.
12 years ago
This is part of my HibernateDAO




Controller DohUtakmica.java

@Controller



I think that my code in POST method isn't correct...
12 years ago
JSP
This is a part of my dohUtakmica.jsp




In listaUtakmica I fetch all the matches from database.

With this code i receive:



Uploaded with ImageShack.us

and the url was

In database the match between Federer and Nadal has id 9. I know that with this code I won't achieve what I want. The problem is that I don't know how to fetch only this particular match.

I hope that the answer isn't fetching from database directly from jsp file because that is against the MVC rules.

Any help is appreciate.
Thank you.

12 years ago
JSP

jatan bhavsar wrote:Hi Jojo,

I receive all matches from database on the new page



Have you try to fetch the data which matches with the id only? You are passing the id in the method so you can retrieve records based on that id and then display on the page.

Regards
Jatan




Exactly that is what I want to achieve. I want to fetch only the match whose ID I have in the url.
12 years ago
JSP
Hello everybody!


I have a table with sport events. Table is populated from database.



Uploaded with ImageShack.us



When I click on detalji (details) it should open a new page with details about the match. Result prediction, users comments and so on.

I send the ID of the match through GET method .

The problem is that I receive all matches from database on the new page, but I only want the match that has the ID I sent through GET method.

I hope You understand what I want.

With the next code I receive empty table.

Here is my code:

Controller DohUtakmica.java





Method for fetching ID from DAOimpl





dohUtakmica.jsp

<table cellpadding="5" cellspacing="0" border="3" class="display" id="coolTablica" width="100%" style="border-color: blue;">
<thead>
<tr>


<th> <fmt:message key="odabirSport.domacin"/> </th>
<th> <fmt:message key="odabirSport.gost"/> </th>
<th> <fmt:message key="odabirSport.rez"/> </th>
</tr>

</thead>

<tbody>

<%
String utakmica_id = request.getParameter("id");
%>
<c:if test = "${param.name != null}">

<c:if test="${listaUtakmica.contains(utakmica.utakmica_id) == true}">

<tr>
<td><c:out value="${utakmica.domacin.nazivTeama}"/></td>
<td><c:out value="${utakmica.gost.nazivTeama}"/></td>
<td><c:out value="${utakmica.rezultat}"/></td>
</tr>


</tbody>

</table>


I hope that someone could give me an advice.

Thanks in advance!
12 years ago
JSP
Hello everybody!

I have a form in which I select sport and country with dropdown list and there is also a text box where i write a name for the new team. When I click on save I receive this exception:



Here is my code:

Team.java


NewTeam controller




Part of NewTeam.jsp



I tried to find the cause of the error in debug mode and here is what I received.



Sport_id is 0 and drzava_id is 0 and I don't understand why. I'm out of ideas, please help.
12 years ago
Thanks for your advices .

This are parts of my code files:

SportRepositoryDAO.java




SportRepositoryDAOHibernate.java




SportService.java




SportServiceImpl.java





About the persistence/DB stuff in my JSP. Unfortunately, I didn't know if there exists another way to populate my drop down box. I found this on the web.
Hello everybody!

I have a problem with hibernate exception when i want to insert data to db. This is a part of STS trace.




Java code:




Sport.java



Drzava means Country.


And the part of jsp




When I start the web application and open the page for inserting new Sport for a country, I choose a country and then i write for example basketball. Then I press submit and the exception is there. In db the sport ID is not NULL and I don't know where is the mistake. I've also found this http://blogs.warwick.ac.uk/colinyates/entry/i_hate_hibernate/ but I don't have such a mistake.

Please help.
Thanks in advance!
Jozo

Edited line length on the stack trace to prevent horizontal scroll bars. - Bill