Samson Mlati

Ranch Hand
+ Follow
since Feb 23, 2009
Samson likes ...
Hibernate Oracle Java
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Samson Mlati

Hi,

I followed the simple example found here

http://netbeans.org/kb/docs/web/jsf20-crud.html

Created a crud web app and I am hoping to learn how to customize this so I can solve a problem. My main issue with JPA/EJB is that it seems not able to work with auto_increment values, my JSF pages must have the id which should ideally be generated by MySQL.. I have looked at the annotations in the mapping and the id is marked with annotation IDENTITY, i have tried TABLE and AUTO but none of them work. My pages must send the id value. How do I fix this?

Thanks.

Mlati.
Hi,

I'm displaying database rows in a JTable and wan't to detect when a user selects a different row in the list of rows. The default behaviour is that you can highlight different rows but I don't know what event to listen for or how. Any ideas? My aim is to display fields from the highlighted row in form input types so the user can update them. Thanks

Samson.
12 years ago

Paul Clapham wrote:

Samson Mlati wrote:It seems like there needs to exist a data source somewhere since the stand alone application must run on the database server anyway.



I don't understand this at all. Database server? Does that refer to the MySQL server which you are running? If so then you just connect to it in the basic way which is described in all the JDBC tutorials. "Data source" is usually a term which refers to an object configured into an web application server. You didn't mention any such thing in your original post, which is why I'm confused about that statement.



You are right about datasource, i'm sorry. I meant an xml file with database properties. The swing application will run on the same machine as the database is what i meant by MySQL server. Thanks, I think I've figured out what I need to do.

Paul Clapham wrote:Okay. You posted this in the JDBC forum so I assume you don't have a problem with the GUI part of your question.

You can put the user ID and password in the JDBC URI which you use to connect to MySQL, or you can use the form of DriverManager.getConnection which has parameters specifically for user ID and password. I would choose the latter method myself.



Well, I kinda see what you mean. It seems like there needs to exist a data source somewhere since the stand alone application must run on the database server anyway. I figure I can use the datasource to query and verify if the username/password supplied is valid.
Hi,

I am working on a stand alone swing application with a mysql back end. I need suggestions on how to go about connecting to the database without having to hard code values in an xml file, I want a user to type in their username, password on a form then use that to connect to the database.

Thanks

pooja par wrote:Hi Samson,

Thank you soooooo.. much for the reply.
Issue got resolved

Thanks



Yay!
13 years ago

Samson Mlati wrote:

Tom Rispoli wrote:You may be getting some kind of failure in your jsp. Did you check the log file for your app server? Maybe putting some println statements early in the JSP would help identify if the JSP is being run.



I added some prinln statements and I can see their output on tomcat console...but I still aint getting forwarded to this page. I don't think JSP is the problem because if i request the page by itself it gets rendered completely with the hibernate results showing that the action was successful.




After almost giving up I figured out my mistake. I was forwarding to a JSP page that is a result to another action, I fixed it by configuring my action result to type redirectAction that forwards to the appropriate action. Works like a charm!!
13 years ago

Gaurav Kushwaha wrote:Hi,

I have an application which will be used by multiple users. Currently, I am storing a object in session that will be used by multiple Actions Classes.
I want to avoid using session.
I tried using the ActionContext's getContextMap/parameters but it didn't help as I guess its clearing with every new request.

Please help !!



Why don't you load it in a servlet?
13 years ago

Tom Rispoli wrote:You may be getting some kind of failure in your jsp. Did you check the log file for your app server? Maybe putting some println statements early in the JSP would help identify if the JSP is being run.



I added some prinln statements and I can see their output on tomcat console...but I still aint getting forwarded to this page. I don't think JSP is the problem because if i request the page by itself it gets rendered completely with the hibernate results showing that the action was successful.
13 years ago

Tom Rispoli wrote:Do you have the xwork jar file in your class path? I think xwork might handle the forwarding stuff.



Yes I have xwork-core2.2.1.1.jar in my WEB-INF/lib folder
13 years ago

Tom Rispoli wrote:You may be getting some kind of failure in your jsp. Did you check the log file for your app server? Maybe putting some println statements early in the JSP would help identify if the JSP is being run.



I'm using tomcat 7, the logs don't show anything unusual. I don't know if I'm missing a required jar but I thought forwards must be part of struts2-core.jar ..I have noticed that non of the forwards actually work anymore. For example if I deliberately make the database unavailable to simulate a hibernate exception I still get stuck in a blank action page instead of getting forwarded to the error page.
13 years ago
Hi,

I have my action configured in struts-xml, evidently my action completes succesfully because when I refresh the view I can see the result I expect. However the problem is that my action remains on a blank page after completing. What could be the problem?

Im on struts 2.2.1. Here is my action execute and mapping


public String execute(){
try{
member = new MemberService().saveMember(member);
return SUCCESS;
}catch(Exception e){
return ERROR;
}
}



struts.xml


<action name="addMember" class="action.AddMember"
method="execute">
<result name="success" type="dispatcher">/viewmembers.jsp</result>
<result name="error">/error.jsp</result>
<result name="input">/addMember.jsp</result>
</action>


What am i doing wrong? It should at least forward to the error page if there was an error. And like I said when i manually open the viewmembers.jsp I can see that my hibernate code worked perfectly. Help.


13 years ago

pooja par wrote:Hi All,

I want to use datepicker in my app.


My JSP:


<!DOCTYPE link PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
<%@taglib prefix="sj" uri="/struts-jquery-tags"%>
<html>
<head>
<link rel="STYLESHEET" type="text/css" href="codebase/dhtmlx.css">
<script src="codebase/dhtmlx.js" type="text/javascript"></script>
<script src="JS/DateValidation.js" type="text/javascript"></script>

<sx:head />
<sj:head />
</head>

<div style="width=100%;" align="center" >
<div ><h2>Add Manager Interest</h2></div>


<s:form action="CreateManagerInterest" namespace="/" method="POST" theme="simple" name="ManagerInterestBean">

<table width="50%" >
<tr>
<td align="left"><s:label value= "Manager*:"/></td>
<td align="left">
<s:url id="managerslist" action="ManagersAutoCompleter" />
<sx:autocompleter name="mgrIntrstBean.manager" href="%{managerslist}" loadOnTextChange="true" loadMinimumCount="1"
cssClass="dhxlist_txt_textarea" dropdownHeight="150px" forceValidOption="true" required="true"/>
</td>
</tr>
<tr>
<td align="left"><s:label value= "Trader:"/></td>
<td align="left">
<s:url id="traderslist" action="TradersAutoCompleter" />
<sx:autocompleter name="mgrIntrstBean.trader" href="%{traderslist}" loadOnTextChange="true" loadMinimumCount="1"
cssClass="dhxlist_txt_textarea" dropdownHeight="150px" forceValidOption="true"/>
</td>
</tr>

<tr>
<td align="left"><s:label value= "Good Until:"/></td>
<td align="left">
<sj:datepicker name="mgrIntrstBean.expiry" displayFormat="MM/dd/yyyy"/>

</td>

</tr>

<tr>
<td align="center" colspan="2"><s:submit value="Submit" align="center" /></td>
</tr>

</table>
</s:form>

</div>
</body>
</html>

I downloaded the jar struts2-jquery-plugin-2.5.3.jar

when I run the app I get the below error

org.apache.jasper.JasperException: /interestInputScreen.jsp(162,8) The sj:datepicker tag declares that it accepts dynamic attributes but does not implement the required interface
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:802)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:865)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
at org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1763)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:347)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:326)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:416)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)


Please help me

Thanks






What struts version? With struts 2.2.2.1 all you need is <%@taglib prefix="sj" uri="/struts-jquery-tags"%>
Struts-dojo-tags are deprecated. The jar you downloaded is all you need besides the tag above. Try deleting

<%@ taglib prefix="sx" uri="/struts-dojo-tags"%> and see what happens.
13 years ago
I managed to fix my error but...my action wont forward. I fixed it by ignoring any xml validation, the date picker accepts date format mm/dd/yy
13 years ago
Anybody here? When I use the date formate dd/mm/yy I dont get the "invalid data for field" error but my xml validation still thinks no dates were submitted. Also I have used "get" for my form method so I can see if the date is indeed getting submited and yes they are being submitted. However this is how the submitted dates look like

member.dateOfBirth=02%2F03%2F1977&member.dateOfMembership=04%2F01%2F2011

Any ideas whats going on with this date picker/validation.
13 years ago