Help coderanch get a
new server
by contributing to the fundraiser

Bob Little

Greenhorn
+ Follow
since Jun 14, 2009
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 Bob Little

Rob Camick wrote:> But if I re-poll the window size and position later when the app is closing, the size is different than originally reported even if I don't resize the main window.

Post your SSCCE that demonstrates this behaviour.



Thanks for the reply Rob.
I haven't been able to reproduce this on a smaller scale to 100% satisfaction. But I've at least seen something that gave me a clue.

When the following code is compiled and run, the behavior is as I'm expecting. If the call to setBounds is commented out and the code recompiled and rerun, the window width and height after pack differs from when windowClosing is invoked. This tells me that I've created the behavior I've described through some incorrect combinations of object construction and size setting methods (or lack thereof). I'm thinking that as a result, Swing is left to calculate the size and location based on some defaults, which may or may not be what I am expecting.

In my full application, I was pretty sure I had called setBounds on all the components I'm using, but I cannot be sure right now.
Being that I have a ton of components spread out over several tabs, its probable I haven't done something right somewhere.


So this topic can be considered solved. Cause: Loose Nut Behind Keyboard.
-bob

13 years ago
Hello,

I have a swing app that uses JFrame as it's main window. It contains a JPanel with several JTabbedPaneS and lots of components. The app reads a ResourceBundle containing the last size and location. During the WindowEvent.WINDOW_CLOSING event, I want to poll the JFrame's current size and location, then save it in the ResourceBundle file.

After I load up all the tabs, panels, components etc., and invoke the JFrame.pack() method, the JFrame size is not what was recorded in the properties file, which is as expected. But if I re-poll the window size and position later when the app is closing, the size is different than originally reported even if I don't resize the main window.


ResourceBundle at app start:


Main window init:


Window close method:


I clearly don't understand something about the behavior of pack() or the Swing framework.

I'm unsure of how the JFrame.pack() figures out its padding so I can adjust for it at app close. Also I don't know why the getBounds() method would report two different sets of values - even if no change has been made to that JFrame.

Any advice would be helpful.

Thanks
-bob
13 years ago

Samuel Goldschmidt wrote:Could you perhaps post instructions on how to set up you project? I tried to replicate it in my NetBeans, but didn't get far - if I copy the jsp code into a new "Visual JSF page" or something like that, I just get "markup preceding the root ... must be well-formed" and I didn't know where to put the faces.config.xml



Hello Samuel,

I believe, as you do, that my problem has more to do with how I set up the project initially than it does with a syntax error or incorrect usage.

I found that the non-working implementation had references to both Standard JSF and Visual Web JSF frameworks. The new, working version of the project has only the standard JSF framework referenced. I think there may likely be a conflict when both frameworks are referenced in a project.

I've created a new project, and added all the components from the previous one to the new one and my commandLink is now working as it should. Anyway, the problem seems solved now.

Thanks for your input Samuel!

-bob
15 years ago
JSF
I have a JSF application in which I want to use h:commandLink and f:param tags. The commandLink on it's own works but as soon as I add the f:param tag, the link no longer works.

I found an example that seems to work correctly: http://www.javabeat.net/tips/44-hcommandlink-how-to-pass-parameter-to-next.html. When I create a new project in NetBeans, and use the files from the example, it works.

However when I create these same files within my own application in NetBeans 6.5 (via "File->New File->Web->JSP" and "File->New->Java->Java Class"), then copying the example code into the new pages, and the relevant faces-config.xml section to my own faces-config.xml file, the commandLink no longer works. The obvious conclusion is that there's something different in my own application that's affecting the way the code is supposed to work.

In looking at the HTML source code generated, and comparing the working example with my non-working implementation of the same code, I found that the working version contains generated javascript, and the non-working version contains no generated javascript.

Seemingly, the reason my implementation does not work is that the javascript is missing.

My question is this:
Is this a NetBeans thing issue do you think? If so, how do I tell NetBeans to generate the javascript for the commandLink tag?

Thanks
-bob


The JSP source code:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>

<html>
<body>
<f:view>
<h:form id="commandLink">
<h:commandLink value="Test Link" action="#{commandLinkBean.linkIt}">
<f:param name="param1" value="ParamValue1" />
<f:param name="param2" value="ParamValue2" />
</h:commandLink>
</h:form>
</f:view>
</body>
</html>



******** Example faces.config.xml ***************************************************
<?xml version='1.0' encoding='UTF-8'?>
<!-- =========== FULL CONFIGURATION FILE ================================== -->

<faces-config version="1.2"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">

<managed-bean>
<managed-bean-name>
commandLinkBean
</managed-bean-name>
<managed-bean-class>
com.webfront.CommandLinkBean
</managed-bean-class>
<managed-bean-scope>
request
</managed-bean-scope>
<managed-property>
<property-name>param1</property-name>
<value>#{param.param1}</value>
</managed-property>
<managed-property>
<property-name>param2</property-name>
<value>#{param.param2}</value>
</managed-property>
</managed-bean>
<navigation-rule>
<navigation-case>
<from-outcome>
commandLink
</from-outcome>
<to-view-id>
/CommandLinkResults.jsp
</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>


********** My Application's faces.config.xml *******************************************
<?xml version='1.0' encoding='UTF-8'?>

<!-- =========== FULL CONFIGURATION FILE ================================== -->

<faces-config version="1.2"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
<!-- Test stuff -->
<managed-bean>
<managed-bean-name>
commandLinkBean
</managed-bean-name>
<managed-bean-class>
com.webfront.CommandLinkBean
</managed-bean-class>
<managed-bean-scope>
request
</managed-bean-scope>
<managed-property>
<property-name>param1</property-name>
<value>#{param.param1}</value>
</managed-property>
<managed-property>
<property-name>param2</property-name>
<value>#{param.param2}</value>
</managed-property>
</managed-bean>
<navigation-rule>
<navigation-case>
<from-outcome>
commandLink
</from-outcome>
<to-view-id>
/CommandLinkResults.jsp
</to-view-id>
</navigation-case>
</navigation-rule>
<!-- end of Test stuff -->

<managed-bean>
<managed-bean-name>app</managed-bean-name>
<managed-bean-class>com.webfront.ApplicationBean</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>ses</managed-bean-name>
<managed-bean-class>com.webfront.SessionBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>req</managed-bean-name>
<managed-bean-class>com.webfront.RequestBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>totes</managed-bean-name>
<managed-bean-class>com.webfront.controllers.ToteController</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>connection</property-name>
<value>#{app.connection}</value>
</managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>inventory</managed-bean-name>
<managed-bean-class>com.webfront.controllers.InventoryController</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>connection</property-name>
<value>#{app.connection}</value>
</managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>categories</managed-bean-name>
<managed-bean-class>com.webfront.controllers.CategoryController</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>connection</property-name>
<value>#{app.connection}</value>
</managed-property>
<managed-property>
<property-name>selectedCat</property-name>
<value>#{param.selectedCat}</value>
</managed-property>
</managed-bean>

<!-- Menu navigation rules -->
<navigation-rule>
<navigation-case>
<from-outcome>totesList</from-outcome>
<to-view-id>/ToteListing.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>toteContents</from-outcome>
<to-view-id>/ToteContents.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>itemSearch</from-outcome>
<to-view-id>/InventoryItem.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>catEntry</from-outcome>
<to-view-id>/Categories.jsp</to-view-id>
</navigation-case>
</navigation-rule>

<!-- Totes pages navigation rules -->
<navigation-rule>
<from-view-id>/ToteListing.jsp</from-view-id>
<navigation-case>
<from-action>#{totes.newTote}</from-action>
<from-outcome>ok</from-outcome>
<to-view-id>/ToteForm.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/ToteForm.jsp</from-view-id>
<navigation-case>
<from-action>#{totes.cancel}</from-action>
<from-outcome>cancel</from-outcome>
<to-view-id>/ToteListing.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/ToteContents.jsp</from-view-id>
<navigation-case>
<from-action>#{inventory.edit}</from-action>
<from-outcome>edit</from-outcome>
<to-view-id>/InventoryItemEdit.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>

<!-- Inventory pages navigation rules -->
<navigation-rule>
<from-view-id>/InventoryItem.jsp</from-view-id>
<navigation-case>
<from-action>#{inventory.search}</from-action>
<from-outcome>ok</from-outcome>
<to-view-id>/InventorySearch.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/InventorySearch.jsp</from-view-id>
<navigation-case>
<from-action>#{inventory.reset}</from-action>
<from-outcome>reset</from-outcome>
<to-view-id>/InventoryItem.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/InventoryItemEdit.jsp</from-view-id>
<navigation-case>
<from-action>#{inventory.update}</from-action>
<from-outcome>update</from-outcome>
<to-view-id>/ToteContents.jsp</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-action>#{inventory.cancel}</from-action>
<from-outcome>cancel</from-outcome>
<to-view-id>/ToteContents.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>

<!-- Categories navigation -->
<navigation-rule>
<from-view-id>/Categories.jsp</from-view-id>
<navigation-case>
<from-action>#{categories.addCategory}</from-action>
<from-outcome>added</from-outcome>
<to-view-id>/CategoryForm.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/CategoryForm.jsp</from-view-id>
<navigation-case>
<from-outcome>cancel</from-outcome>
<to-view-id>/Categories.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
<navigation-rule>
<navigation-case>
<from-outcome>cancel</from-outcome>
<to-view-id>/Categories.jsp</to-view-id>
</navigation-case>
</navigation-rule>

</faces-config>
15 years ago
JSF