jack catler

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

Recent posts by jack catler

Late addition to this thread....

Based on the example I put together the following servlet thread test..

I was curious and commented out the 'interrupted = true' flag setting as you can see...but...it STILL stops the thread....why is that?

import java.lang.Thread;

public class ConnCheck extends Thread {

private boolean interrupted = false;

private int interval;

public ConnCheck(int interval) {
this.interval = interval;
}

public void run() {

setPriority(Thread.MIN_PRIORITY);

try {
while (true) {
if(isInterrupted()) break;
Thread.sleep(interval);
// ..do stuff....
}
}
catch(java.lang.InterruptedException e) {}
}


// !!! This still stops the thread even with this comment!
synchronized public void stopMe(){
// interrupted = true;
interrupt();
}

synchronized public boolean isInterrupted() {
return interrupted;
}
}


I call the stopMe() function from another servlet which gets a handle to the connCheck servlet from servletContext.

i.e.
ConnCheck d = (ConnCheck)getServletContext().getAttribute("conncheck");
d.stopMe();

It stops it...but why?

Thanks
Ok I found it. Just FYI for other beginners.

I picked up the parameters in the contructor of the bean by getting a hold of the session object, then created the list.
18 years ago
JSF
This should be simple...but I am not sure how to do it.

How do create a simple request scope bean which needs an ID passed to it to be constructed. The ID is used so the bean create a HashMap which I will then display using a dataTable. Couldn't be simplier..but I'm stuck.

The ID is passed to the page via javascipt function in the URL which then the page extracts using the param object.

// e.g. Display passed id parameter on the page.
<h utputText value="#{param.passed_id}" />



Thanks
18 years ago
JSF
Thanks, it works. Actually the second example in my first post was working - same as your recommendation.

<h OutputText value="#{sessionObj.mymap[thekey].name}" />

..it was being obscured by the nature of some other output - and not enough coffee on my side....

Thanks a lot!
18 years ago
JSF
Thanks for the reply, Yes I am using JSF. I should clarify 'sessionObj' in the example is exactly that, a session bean, the data structure (rougly) is:

public class sessionObj {
private HashMap<String, myBean> mymap;
public HashMap<String, myBean> getMymap() {return mymap;}
....
}
public class myBean {
private String name;
public String getName() {return name;}
....
}

So now in the jsp file, I have the key I want for the hashmap entry, how do I go straight to it?

The example you give (the firt one that is) would return the object, but I want to go directly to the field within the object. I had a look at the link you gave, not really there.

Thanks!
18 years ago
JSF
Trying to display a simple name from an objects located in a map.
The map is in a session based object.

Neither of the statements below work.

1. <h utputText value="#{sessionObj.mymap[thekey][name]}" />

2. <h utputText value="#{sessionObj.mymap[thekey].name}" />

Am I even close?
18 years ago
JSF
Should the following setting of 'id' work, or do I have to use binding ?

<h:selectBooleanCheckbox id="#{mybean.theId}" value=" {mybean.selected}"/>

// the getter..
public String getTheId() { return this.Id;}

There is an ocean of talk on this, but none 'seem' to go straight to the point.

I just want to set the id at runtime from the bean, would prefer this way than then binding.

Thanks!

[ April 12, 2006: Message edited by: jack catler ]
[ April 12, 2006: Message edited by: jack catler ]
19 years ago
JSF
Have been plugging away at this...I am totally stuck...perhaps JSF cannot do this?

I have not posted code as eveything I tried failed....badly...

I am handed a bean in my application.
The bean contains two things, a list of column names, and a list of row entries. Each bean has it's own column names. (I am able to reformat/change the way these are handed to me if I wish).

How do I display each bean in it's own basic table with column heading using JSF?

I have tried of dataTable <foreach>, panelGrid and combinatins - all failed.

any help really appreciated.
Thanks!
19 years ago
JSF
I don't even now if this is doable....is it?

My bean returns a list of objects. Each object represents an individual table and contains a column object for the headers, and a row object with elements. Plan is for the final page to contain a number of tables with column names and results. User then eyeballs the whole lot by scrolling up/down the page - i.e. page of tables each table having potential different columns and data.

I was thinking about creating two dataTables for each result object, one containing the column names, the other the data, all wrapped around an outer dataTable...confused..me also..

I am quite new to JSF and am now wondering if it is possible given the dynamics of what I want to achieve. That is, I don't know the number of columns or their names.

Another option is to go to straight JSP and process....

Any opinions?

Thanks!
19 years ago
JSF
I have a number selectOneListbox items on the same JSP page.

They are logically connected in a tree type structure, selecting list A will fill list B, selecting list B will fill list C and so on. I also clear the lists as required.

Each list has a Listener handler valueChangeListener which performs a number of actions:
- Gets the new value.
- clears the current list.
- Updates the lists based on the selection.

Works OK 50% of the time but then depending on sequence (and luck/timing?), some selections of list items (up the tree) cause the valueChangeListener events of other lists to be fired with null/unselected values. I have done some searching and I believe it's a timing issue but thats all I can determine. I am quite new JSF...


Example of the list declerations follows...

<tr><td>List A</td></tr>
<tr><td>
<h:selectOneListbox immediate="true" onchange="submit()"valueChangeListener="#{myclass.listAChanged}">
<f:selectItems value="#{myclass.listA}" />
</h:selectOneListbox>
</td></tr>

<tr><td>List B</td></tr>
<tr><td>
<h:selectOneListbox immediate="true" onchange="submit()"
valueChangeListener=" {myclass.listBChanged}">
<f:selectItems value="#{myclass.listB}" />
</h:selectOneListbox>
</td></tr>

<tr><td>List C</td></tr>
<tr><td>
<h:selectOneListbox immediate="true" onchange="submit()"
valueChangeListener="#{myclass.listCChanged}">
<f:selectItems value="#{myclass.listC}" />
</h:selectOneListbox>
</td></tr>

Example of valueChangeListener follows...

public void listAChanged(ValueChangeEvent event){

FacesContext fc = getFacesContext();
String newAString = (String)event.getNewValue();

// listB is a Map object...
listB = getNewBList(newAString);
listC.clear();


fc.renderResponse();
}


When I play around with the list selection screen I get (without explanation) null events or events that refer to lower lists (say listC) without even having selected them...it is kinda driving me el nutso...

Any tips greatly appreciated.

Thanks
19 years ago
JSF
Thanks for the reply.

So you are suggesting a pool of session objects dished out as requested and ID keys to these objects in a hidden field on the JSP page - and thus enable the linkage of the two? Sounds reasonable and I guess it should work.

I guess I could set a limit on the size of the pool, and use a LIFO for picking the victim object when a new request comes in and the pool is used.

I am most curious to know if this (or a deviation of this) is the general solution most people use? I imagine this problem is not unique to myself or JSF, how do others handle a user opening new windows on the same session and referencing the same session objects from these different windows?

Thanks again.
19 years ago
JSF
This probably relates to servlet/jsp just as much as JSF - but here goes anyway.

My application allows the user to open a number of search windows (i.e. they can right click - new window). The result of the search creates a result object which needs session scope so they can sort the result, stick in shopping basket, and other actions.

What is the best way to assign/keep a specific session scoped result bean to the SPECIFIC jsp page ?

Can you exit with a parameter/status so the jsp page will embed a type of ID a thus create the mapping? What does the JSF navigation allow ?

Many thanks
19 years ago
JSF
This may relate to servlet/jsp just as much as JSF, however it would be interesting to know how JSF handles this.

My application allows the user to open a number of search windows (i.e. they can right click - new window). The result of the search creates a result object which needs session scope so they can sort the result, stick in shopping basket, and other actions.

What is the best way to assign/keep a specific session scoped result bean to the SPECIFIC jsp page ?

Can you exit with a parameter/status so the jsp page will embed a type of ID a thus create the mapping? What does the JSF navigation allow ?

Many thanks!
19 years ago
JSP
I know this thread went silent a while back, but it is the topic of interest for me.

One question, leading on from Kevin's summary (which I found very helpful...), does that mean (in the end) a bean DOES need to impliment Serializable to allow the use of STATE_SAVING_METHOD on either Client or Server ?

Thanks!
19 years ago
JSF
Curious....what was it ?
19 years ago