A Harry

Ranch Hand
+ Follow
since Jan 23, 2002
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
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by A Harry

many thanks for that, working my way through it now - I can if I wish do all file I/O from the WAR, is that possible/safe?
I have an EAR containing a WAR & several EJBs (running on Weblogic 9.2, not sure if that makes any difference though)

From either an EJB or WAR I need to be able to create and read external files. Is this possible?

So, if I created a file from the EJB (with no path) say "abc.txt", where will it be created and how would I read that from the WAR - and vice versa?

thanks in advance
as a matter of interest, if you place a shared JAR (say abc.jar) in the EAR APP-INF\lib directory and you want an EJB to use it, would you have to include the lib folder in the manifest file? i.e. should the manifest entry be lib/abc.jar or just abc.jar ?

can't find anything anywhere that says to or not
6 years ago
in fact just noticed in the logging output I get this -

<Rendering view with name 'listreturns' with model null and static attributes {}>

surely the model should be an object not null?
Using Spring 2

I have 2 JSP pages both have SimpleFormControllers behind them -

public class LoginController extends SimpleFormController{
....

public class ListReturnsController extends SimpleFormController{
....


what I want to do is when the Login button is pressed on login.jsp control passes to listreturns.jsp and methods like ListReturnsController's referenceData() get called to prepopulate it etc... BEFORE the actual listreturns.jsp is displayed?

I thought this would very simple but as a newbie it's not to be!

So basically my login.jsp looks like this -

<form:form method="POST" action="login.htm" commandName="login">
...
<input type="submit" name="_login" value="Login" />

In LoginController - onSubmit() I'm doing this -

protected ModelAndView onSubmit(HttpServletRequest request, ..........) throws Exception
{
......
if (WebUtils.hasSubmitParameter(request, "_cancel"))
{
return new ModelAndView("listreturns");
}
......

but listreturns.jsp is opened WITHOUT referenceData() being called!

Can anyone help? - I know it's bound to be sonething stupid I'm doing/not doing but just can't see it at the moment?

my config file looks like this -

<beans>
<bean id="loginController"
class="uk.gov.ea.gor.controller.LoginController">
<property name="formView" value="login" />
<property name="successView" value="listreturns" />
</bean>

<bean id="listReturnsController"
class="uk.gov.ea.gor.controller.ListReturnsController">
<property name="formView" value="listreturns" />
<property name="successView" value="changepassword" />
</bean>

<bean id="changePasswordController"
class="uk.gov.ea.gor.controller.ChangePasswordController">
<property name="formView" value="changepassword" />
<property name="successView" value="listreturns" />
</bean>

<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/login.htm">loginController</prop>
<prop key="/listreturns.htm">listReturnsController</prop>
<prop key="/changepasssword.htm">changePasswordController</prop>
</props>
</property>
</bean>

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass">
<value>org.springframework.web.servlet.view.JstlView</value>
</property>
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>

thanks in advance & hope I've explained this properly!

harry
not sure if this helps as I'm quite new to the JSF world but this is my web.xml file, created in eclipse + myeclipse plugin also tomahawk library added!

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>/WEB-INF/tomahawk-taglib.xml</param-value>
</context-param>
<listener>
<listener-class>
org.apache.myfaces.webapp.StartupServletContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>MyFacesExtensionsFilter</filter-name>
<filter-class>
org.apache.myfaces.webapp.filter.ExtensionsFilter
</filter-class>
<init-param>
<param-name>maxFileSize</param-name>
<param-value>20m</param-value>
</init-param>
</filter>

<!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages -->
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry -->
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>

<!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.) -->
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
</filter-mapping>
<!--Tomcat 5 Workaround: Listener used to initialize JSF on startup-->
<!--Remove comment tags to enable listener.
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
-->
<!--Tomcat 5 Workaround: Listener implementation to handle web application lifecycle event-->
<!--Remove comment tags to enable listener.
<listener>
<listener-class>com.sun.faces.application.WebappLifecycleListener</listener-class>
</listener>
-->
</web-app>
10 years ago
JSF
I have 2 drop down boxes, the 2nd is populated based on the 1st's value like so -

<h:selectOneMenu value="#{airportHandler.airport}"
valueChangeListener="#{airportHandler.changeDestinationAirports}"
onchange="this.form.submit()" immediate="true" >
<f:selectItems value="#{airportHandler.airports}" />
</h:selectOneMenu>

so changeDestinationAirports populates a list object which the 2nd one uses!

The trouble is changeDestinationAirports is fired BEFORE the airportHandler.airport setter so airport does not show the current selected value - I can set this in the handler before I populate the list object for the 2nd drop down but is there anyway to get JSF to call the setter before the valueChangeListener gets fired?

thanks!
10 years ago
JSF
OMG! after hours of J2EE typical painstakingly stressful messing about I found it!

If you do not specify the column attribute on the <many-to-many> line, hibernate in its wisdom bizarrely assumes a column call "elt"!!!

so for anyone else this line does it -

<many-to-many class="test.EventManyToMany" column="event_id"/>
that's it then - tried everything I can find & there is no way on this earth hibernate will populate event_id & speaker_id fields correctly!

Is this just a specifc problem with Oracle or is it a bug with many-to-many relationships in hibernate in general?

Has anyone else come across this with Oracle? has anybody any advice? should I drop hibernate & use something more reliable? - totally lost now!
I have what I think is a very simple many-to-many relationship, 2 tables "m_events" & "m_speakers" joined in table "event_speakers"

////////////////////////////////////////////////////////////////
<hibernate-mapping>
<class name="test.SpeakerManyToMany" table="m_speakers">
<id name="id" column="id" type="long">
<generator class="increment"/>
</id>
<property name="firstName" type="string" length="20"/>
<property name="lastName" type="string" length="20"/>
<set name="events" table="event_speakers" cascade="all">
<key column="speaker_id"/>
<many-to-many class="test.EventManyToMany"/>
</set>
</class>
</hibernate-mapping>

<hibernate-mapping>
<class name="test.EventManyToMany" table="m_events">
<id name="id" type="java.lang.Long">
<generator class="increment"/>
</id>
<property name="name" type="string" length="100"/>

<set name="speakers" table="event_speakers" cascade="all" inverse="true">
<key column="event_id"/>
<many-to-many class="test.SpeakerManyToMany"/>
</set>
</class>
</hibernate-mapping>

////////////////////////////////////////////////////////////////

Test code -

Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();

EventManyToMany event = new EventManyToMany();
event.setName("Inverse test");

event.getSpeakers().add(new SpeakerManyToMany("John", "Smith", event));
event.getSpeakers().add(new SpeakerManyToMany("Dave", "Smith", event));
event.getSpeakers().add(new SpeakerManyToMany("Joan", "Smith", event));

session.save(event);

tx.commit();
HibernateUtil.closeSession();

HibernateUtil.sessionFactory.close();

////////////////////////////////////////////////////////////////

All 3 tables are populated but the event_id column in "event_speakers" is null and speaker_id is set correctly.

If I move inverse="true" in to the first file then event_id column in "event_speakers" is now set correct but speaker_id is null

inverse="true" in both files does not insert a record into "event_speakers"!

How can I do this so both event_id & speaker_id are set correctly? - this is really doing my head in, I've tried every combinantion I can think of but it just doesn't for what I want!

Probably something stupid I'm doing/not doing but any ideas?

thanks

harry
is there a better way of returning a value from an Oracle sequence than using something like session.createSQLQuery("select myseq.nextval from dual")

thanks

harry
Sorry but a bit new to this!

I'm trying to persist an enum type to Oracle using Hibernate - I've followed the procedure as shown here http://www.hibernate.org/312.html but what I can't get my head around is how use it in my case - rather than store the ordinal position of the string I'd like to store the enum's id value ?

Any ideas how to modify the example to do this?

My enum looks like this -

public enum Status {
DRAFT(0, "Draft"), RUNNING(1, "Running"), FAILED(2, "Failed"), FINALISED(3, "Finalised");

private intid;
private Stringstr;

private Status(int id, String str) {
this.id = id;
this.str = str;
}

public int getID() {
return this.id;
}

public String toString() {
return this.str;
}

public static Status valueOf(int id) {
for (Status status : Status.values()) {
if (status.getID() == id) {
return status;
}
}
return null;
}
}

many thanks in advance for any help!

harry
but been thrown in the deep end a bit with some JSF stuff!

Can anyone please tell me how to test for a string in the following example instead of a int?

<h:graphicImage value="/images/Flag.gif" rendered="#{line.status.ID == 2}"/>

I need to check if line.status = "TEST STRING" then & only then display the image?

thanks ever so much in advance, will sit down when time & learn it properly!
10 years ago
JSF
I am currently 1.4 SCP and am looking move up to 1.5 - there appear to be 2 exams I can take -

Sun Certified Programmer for the Java 2 Platform, Standard Edition 5.0 Upgrade Exam (CX-310-056)

or

Sun Certified Programmer for the Java 2 Platform, Standard Edition 5.0 (CX-310-055)

do I need to do just the "upgrade" one then? both are the same price but the upgrade has fewer questions, less exam time etc...

thanks in advance

harry
thanks for you views, just wanted someone to tell me what I thought was the right way to to go anyway!