Marius Snyman

Greenhorn
+ Follow
since May 04, 2006
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 Marius Snyman

I solved my triplicate request by setting ajaxSingle=true on the a4j:commandLink and on the rich:panelMenuItem
14 years ago
JSF

Originally posted by Sasha Baker:
I need to set visibility of an UIInput component programmatical and with a binding:

<h:inputText rendered="#{mybean.visisble}" />

uiInput.setRendered(boolean); doesn't do the job.

Instead I tried:


It doesn't work.



I suggest that instead of doing:
rendered="#{mybean.visisble}"
do:
binding = "{BB.inputText}"


Then in the backing bean on some condition activate the inputText
example:
BB:
HtmlInputText inputText = new HtmlInputText();

constructor(){
inputText.setRendered(false);
}
public void someMethod(){
inputText.setRendered(false);
}

If you look at the JSF documentation you will see that when the object property is changed JSF will re-render the object. The way you have done it the re-render will not occur. Hope this helps.
14 years ago
JSF

Originally posted by Harihara Sudhan:
i done logout operation.but url is copy to browser the page go.pleases anybody help this?



Here is a suggestion:
1. Create a class that implements PhaseListener
2. In the beforephase method validate which pages may be seen.
3. Also determine whether a use object exists.
4. If the client is visiting a page that requires a login reroutes the client to the login or a session expired page.

Example:
public class LoggedOnPhaseListener implements PhaseListener {

private static final long serialVersionUID = 7805022367671101424L;
private static final Log logger = LogFactory.getLog(LoggedOnPhaseListener.class);

public LoggedOnPhaseListener() {
logger.info("LoggedOnPhaseListener created");
}

@Override
public PhaseId getPhaseId() {
return PhaseId.RENDER_RESPONSE;
}

@Override
public void beforePhase(PhaseEvent ev) {

boolean expire = false;
FacesContext facesContext = ev.getFacesContext();

// We going to the logon page or the expire page
boolean loginPage = facesContext.getViewRoot().getViewId().lastIndexOf("login") > -1 ? true : false;
boolean forgottenPasswordPage = facesContext.getViewRoot().getViewId().lastIndexOf("forgottenPassword") > -1 ? true : false;
boolean forgottenUsernamePage = facesContext.getViewRoot().getViewId().lastIndexOf("forgottenUsername") > -1 ? true : false;
boolean adminReactivationPage = facesContext.getViewRoot().getViewId().lastIndexOf("adminReactivation") > -1 ? true : false;
boolean expirePage = facesContext.getViewRoot().getViewId().lastIndexOf("sessionExpire") > -1 ? true : false;

if (!loginPage && !expirePage && !forgottenPasswordPage && !forgottenUsernamePage && !adminReactivationPage && !loggedIn(facesContext)) {
expire = true;
}

if (expire) {
logger.info("user session is not valid... logging out");
facesContext.getApplication().getNavigationHandler().handleNavigation(facesContext, null, "sessionExpired");
}

}

@Override
public void afterPhase(PhaseEvent ev) {
}

private boolean loggedIn(FacesContext facesContext) {
boolean result = true;
Map<String, Object> smap = facesContext.getExternalContext().getSessionMap();
if (smap.containsKey("loggedOnDetails")) {
LoggedOnDetails details = (LoggedOnDetails) smap.get("loggedOnDetails");
if (details.getUserDTO() == null) {
result = false;
}
} else {
result = false;
}
return result;
}
}
14 years ago
JSF

Originally posted by Yasir Qureshi:
I want to display list A and also list B which is contained by list A, in the same data table.



In you backing add two HTMLDatatables
private HtmlDataTable dataTableA;
private HtmlDataTable dataTableB;
private List ListA ;
private List ListB ;


On your web page link:
<h:dataTable id="itemsA" bindings="#{bbean.dataTableA}" value="bbean.ListA">
<h:dataTable id="itemsB" bindings="#{bbean.dataTableB}" value="bbean.ListB" rendered="false">

Add the entries of ListA to dataTableA
Add A commandLink to a column in dataTableA which calls a method in the backing bean:

ex:
<h:commandLink action="#{bbean.selectDetail}">
<h:outputText value="Show Detail"/>
</h:commandLink>

in the backin bean method set the rendering for tableB to true
public void selectDetail(){
ListB = ListA.ListBData
ListB.setRendered(true)
}

You will then display your data as a sort of Master/Detail record on the web page.
14 years ago
JSF
I have faces page called myworklist.xhtml.

On this page I use a richfaces datatable to display available work objects.

When a user clicks on a hyperlink the specific work item is retrieved from the database.

I notice the following:
During the initial load the backing bean reads the database 3 times before the pages is rendered. The same data is therefore retrieved 3 times from the database.

When the user selects an item the database is again read 3 times before the work item is displayed.

On the workpage, a button allows the user to take ownership of the workitem. At this time a jbpm process is updated with the task being assigned to the user.

Because 3 trips are made during each call, the jbpm process is asked to assign the task to the user thrice. On call 2 the jbpm process will throw an error.

I have been unable to determine why my backing bean methods are called multiple times and wondered if any hand on the ranch can maybe shed some light on this.
14 years ago
JSF
I have downloaded the latest sources and this was not addressed yet.

Maybe the authors can look at this as well:

On Page 155, the releaseLock Method does an == test. i.e.

if (reservations.get(upc) == renter) {

Should this not rather be an .equals. as in
if (reservations.get(upc).equals.(renter)) {
I personally find Monkhouse's book very helpful. I was forced into Java because of a business need. I did not get the time to come to terms with a lot of the basics of Java. In order to understand Java I took the SCJP, barely made it, and realized that it would make a lot of sense to pursue the Java certification path.

I write middleware using EJB's, JPA , etc, and therefore do not get to use a lot of the basic development stuff (file IO, GUI, threading, etc..) but work a lot with Patterns, the services the Application Servers provide (pooling, persistence, etc..), and functionalities exposed by 3rd party open-source providers. Working with different technologies in this regard made me question a lot of the implementations out there.

Working through Monkhouse's book I now understand a whole lot of those implementations better. I can also now appreciate the "otherness" of some of these implementations. Many of the basics of Java is refreshed and some concepts fastened more thoroughly in my mind.

All in all I guess the material goes a long way to making me a better developer, and for that I am gratefull. I believe the book is worth every cent spent.

I consider it an essential help in achieving my SCJD goal.
Is this for testing purposes only? I see the spec defines sun java only for all development.
Would it be considered an overkill to convert the arrays to field and record objects before passing it to the client. On the client side the objects are interrogated and updated and on the server side the objects are then converted to the arrays during/prior to the write operations.

My project specifies it must allow for enhancements with minimal impact in the client. Hard-coding fields may result in client changes, so I am contemplating using dynamically created/loaded fields and records with the validation in the classes. This way I expect that any future DB layout changes will automatically be accomodated.

Also, do you guys use String by default or do you validate the fields on both client and server for the datatypes. For example. The room can take 4 people. If I use fields and records I can simply build the validation into the class.

My question arises from the issue that I do middleware development for the most part and am so accustomed to working with serializable objects only that it feels akward to think of transmitting the arrays between client and server.

Any guidelines from you guys who already have acquired your SCJD?
I have been using JPA and Hibernate as the persistence provided in JBoss for some time. I cannot fault the specification or the Hibernate persistence provider in any way, as far as my implementations go.

However, I have recently joined a team where it is insisted that HIBERNATE, or any other persistence provider will not DO. The primary reasons are; Hibernate takes away the control they have on the SQL, and the underlying database. JPA according them is a problem because your database is managed in code. If you add Views, Stored Procedures, triggers, etc later it gets lost.

Their solution is using DAO and JDBC. The reasoning behind this is you have absolute control over your DB design, DB Access and SQL Queries.

It is up to me to convince them JPA serves the purpose. The moment I mention Hibernate, I see the "not-interested" look cross their faces.

Talking about patterns, service abstraction and layered design draw nothing but blanks. The impression one gets is one where peoply think you are adding complexity to what they consider should be a straight forward, no-hassle, just code it and get it done with, problem domain. Actually they were quit clear on it that some architects just like to complicate things with highly unprobable what-if's.

In my investigations I see that JPA can actually be used without Hibernate but I cannot find any examples out there where it is tried. All examples go back to Hibernate, Toplink, and openJPA.

Can you refer me to some examples that I can use as a Proof of Concept to get them convinced otherwise. My requirements are:

1. Build a JPA implementation without Hibernate, TopLink, or OpenJPA.
2. I must be able to change a column type without losing data (drop table, etc)
3. I must be able to add Views, Triggers, etc without loss at any time.

Without benchmarks I shall probably never persuade them.
"Sun Certified Programmer & Developer for Java 2 Study Guide" by Kathy Sierra and Bert Bates is the best book on both exams. The SCJD is a practical project with an essay exam based on the project.

Here are the reviews: http://www.amazon.com/review/product/B000SEGIIG/ref=dp_top_cm_cr_acr_txt?%5Fencoding=UTF8&showViewpoints=1

Otherwise the javaranch provides the best place for tips on the SCJD. Go here:https://coderanch.com/forums/f-25/java-developer-SCJD
I am trying to put together real how-to's for EJB 3.0. Please have a look at http://jroller.com/page/PracticalEJB3 and provide me with your critique.
Saikiran Madhavan, aymane chetibi

I have worked through many of the tutorials on the the sites. Even the JBoss EJB and the JBoss IDE Trails. I have found that mostly it is assumed that you know something about EJB. For example how the deployment descriptors work. I have not worked with EJBs before and therefore was out of the water.

I compiled my own tutorial for testing local and remote client for JBoss 4.0.4 using nothing but textpad. I have forwarded this tutorial to your email acounts. If you find it helpful maybe we can try and get it posted somewhere.