Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

ved gunjan

Ranch Hand
+ Follow
since May 17, 2003
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 ved gunjan

Hi,
Yes telnet is working from machine B.
But still it is not able to listen.
What can be the problem and possible solution. Is there any server setting that needs to be configured.

Regards
Ved
10 years ago
Hi,

We are using JBoss 4.0.5.GA as our application server.

The scenario is like this.

Machine A) IP Address: 192.168.XXX.YYY. [It's the Server] On this Machine Jboss4.0.5.GA and MySQL are running.

The outside system (basically the external clients) refers to this machine through address 220.225.ZZZ.XXX. This is the public ip address.
i.e the external_host_name = 220.225.ZZZ.XXX.

Machine B) it's an external client. It is looking up for service which is running on Machine A through JNDI.
In the client code, the jndi provider URL is set up to "jnp://220.225.ZZZ.XXX:1099" when the initial context is created for the RMI access.

The client code which is running on Machine B) is doing a lookup for the service, using the following jndi.propterties:
Code:

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming rg.jnp.interfaces
java.naming.provider.url=jnp://220.225.ZZZ.XXX:1099

The two machines are running on different network.

When am running the code on the Machine B), and trying to access the service running on Machine A), it is throwing java.naming.CommunicationException: connection refused, cannot connect to url: 220.225.36.247.

Can any one guide me as to where we are going wrong and whether we are missing any setting in the JBoss Server?

I need this fix very urgently...please guide be to the solution.

Thanks and Regards.
Ved.
10 years ago
Ho All,
I need to generate a MS Word Document with data fetched from DB.
If there are any url or sample code exist which can guide me through this.
It would be great any one can provide me with some valuble input.

Thanks and Regards.
Ved
Hi Experts,
Im using injected persistent context in my session bean.
@PersistentContext(unit="AppConext")
private EntityManeger entityManager;

In this session bean i've a method in which,i iterate over the list.
Lets say this method as method1();
The scenario is somthing like this..
@TransactionAttribute(REQUIRES_NEW)
public voic method1()
{
......some code.....
for(SomeObject obj : someObjectList)
{
..............some code....
//call method2
method2(obj);
.........some code......
}
}

@TransactionAttribute(REQUIRES_NEW)
public void method2()
{
}

What is happening here is when i call mehod2 and pass value to it from list,
the method throws NoEntityFound excexption and ejb transaction rolls back.
In the catch block of method2 , i'm catching NoEntityFoundException and getting the programm flow to normal flow.
Throwing of NoEntiyFound exception is an expected behaviour.
But my requirement is that i need to continue the iteration over the other values in the list.

But when the programm comes back to method1 and the moment it does some
procesing i get an EJbTransactionRollBack exceptions , saying generice JDBC exception..cannot open connection..session close....

javax.transaction.RollbackException: Already marked for rollback, tx=TransactionImpl:XidImpl[FormatId=257,

1)What is the technical reson behind exception in method1?
2)What should i do to solve it so that my code processes the rest of the elements in the list?

Thanking in advance for any help.

Thanks
Vedgunjan
Hi,
Im using apache-ant-1.6.5 and jdk1.5.0_10. When im compiling my application using ant, im getting the following exception.It complains about the compiler crash..
Here's the snap shot of the exception im getting.
---------------------------------------------------------
An exception has occurred in the compiler (1.5.0_10). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you. [javac] java.lang.AssertionError: {unused} [javac] at com.sun.tools.javac.tree.TreeMaker$AnnotationBuilder.visitArray(TreeMaker.java:634) [javac] at com.sun.tools.javac.code.Attribute$Array.accept(Attribute.java:124) [javac] at com.sun.tools.javac.tree.TreeMaker$AnnotationBuilder.translate(TreeMaker.java:637) [javac] at com.sun.tools.javac.tree.TreeMaker$AnnotationBuilder.visitCompoundInternal(TreeMaker.java:628) [javac] at com.sun.tools.javac.tree.TreeMaker$AnnotationBuilder.translate(TreeMaker.java:641) [javac] at com.sun.tools.javac.tree.TreeMaker.Annotation(TreeMaker.java:649) [javac] at com.sun.tools.javac.tree.TreeMaker.Annotations(TreeMaker.java:570) [javac] at com.sun.tools.javac.tree.TreeMaker.VarDef(TreeMaker.java:554) [javac] at com.sun.tools.javac.comp.Lower.visitIterableForeachLoop(Lower.java:2892) [javac] at com.sun.tools.javac.comp.Lower.visitForeachLoop(Lower.java:2755) [javac] at com.sun.tools.javac.tree.Tree$ForeachLoop.accept(Tree.java:597) [javac] at com.sun.tools.javac.comp.Lower.translate(Lower.java:1881) [javac] at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:54) [javac] at com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:145) [javac] at com.sun.tools.javac.comp.Lower.visitBlock(Lower.java:2927) [javac] at com.sun.tools.javac.tree.Tree$Block.accept(Tree.java:535) [javac] at com.sun.tools.javac.comp.Lower.translate(Lower.java:1881) [javac] at com.sun.tools.javac.tree.TreeTranslator.visitMethodDef(TreeTranslator.java:129) [javac] at com.sun.tools.javac.comp.Lower.visitMethodDefInternal(Lower.java:2267) [javac] at com.sun.tools.javac.comp.Lower.visitMethodDef(Lower.java:2186)
-----------------------------------------------------

Can any one tell me what's going on here. I need help urgently as im stuck. Any help will be great.

Thanks Ved.
11 years ago
Hi,
Has any one tried DWR and JSF integration..If yes please provide some inputs regarding it.


It would be great if some URL is provided which covers the topic.
Also some working example is provided as ready reference.

Thanks for all the help
Regards
Ved
11 years ago
JSF
hi
you need to use f:subview for this.you will have to nest your included page inside f:subview

here's an example.
<f:subview id="nestedPage">
<jsp:include page="theNestedPage.jsp" />
</f:subview>

thanks.
ved
11 years ago
JSF
Hi Experts,
I'm using DataTable for displaying a dynamic list of objects.
In the rows, i have different number of components,like for example first row might be having input field and slectOneMenu second row might be having two input fields and check boxes.

My query is how do a i get in my java code the different components of a row.

Hope im able to explain my problem. Please throw light on this , as im in dire straits.
Thanks
Ved
11 years ago
JSF
Hi Experts,
I'm to using custom validator in my application.
<h:dataTable value="#{requirementBean.questionList}"
var="questions"
id="questionTable"
columnClasses="none,tableRowOdd"
rowClasses="tableRowEven,tableRowOdd"
cellpadding="1"
cellspacing="1"
width="100%">

...................
.......................
<h:inputText rendered="#{questions.displayType eq 'TextBox'}" id="inputTextid" value="#{questions.defaultAnswerString}">
<f:validator validatorId="dataTypeValidatorId" />
<f:attribute name="dataType" value="#{questions.dataType}"/></h:inputText>


"dataTypeValidatorId" is a custom validator which im using in my application.
The problem is that the f:attribute tag is not working in case of EL expressions, the way i have used above ( <f:attribute name="dataType" value="#{questions.dataType}"/>).
I get value as null in my validator code.
Here's my validator code.

public void validate(FacesContext arg0, UIComponent component, Object value) throws ValidatorException {
Map map = component.getAttributes();
String str = (String) map.get("dataType");
if(str != null && "String".equalsIgnoreCase("str")){
.........
..................
}


But when i put static value in the value attribute of the f:attribute tag , every thing works fine...some thing like this
<f:attribute name="dataType" value="Integer"/>, then i get proper vlaue in the validator code.

Even though the specifications says that f:attribute can take static values as well as EL expressions.

Any ideas? Whats the reason and how to solve it.? It's very important please provide me with some help.

Thanks.
Ved
11 years ago
JSF
Hey Ali,
Thanks for bearing with me...
See i have no problem in displaying the components for each questions. I have succeded in doing that.
The problem is how do i capture the values of these componets,submitted by the user.
The way you suggested is that to have that as many attributes/properties in backing beans as the number of components in jsp...but the problem is that these numbers are dynamic so i cant create these attributes in the backing beans.

so i used the way of valuechangelistener.
i binded these components with valuechangelistener and i've succeded in capturing the values, but now i ran into a major bug.
i had this requirement of displaying defalut values for dropdowns/multiselects/chakbox/radio buttons.
I'm still successful in getting the values for the components whose values are changed from the defalut selection. snice the user changes the default selection the valuechangelistener gets called. but if the user submits with defult selection the valuechangelistener method does not get called.
so i fail for such questions.

My query is:
1) Is my approach correct for my requirement.
2) and how to solve the present bug.

Hope this time it is more clear.
thanks
ved
11 years ago
JSF
Thanks Ali for the reply...
The reason why i cannot create attribute/properties in the Backing beans for each corrosponding UIComponents(h:selectOneMenu,h:selectManyListbox,h:selectOneRadio & h:selectManyCheckbox in the jsp) is that, these components corrosponds to the questions, as you have understood rightly, but these questions are dynamic in nature... means some time there may be 30 quesitions, sometime there may be 20 questions, so now you understand why i cant create the properties/attributes in the backing bean before hand.

So what i have done is that , i have binded these components to valueChangeListiner, and whenever the value changes the implementing method gets called.

I think now things are bit more clear.
Thanks
Ved
11 years ago
JSF
Hi,
Thanks Ali for the reply.

Here's the jsp code:

<h:dataTable value="#{requirementBean.questionList}" var="questions" id="questionTable" columnClasses="none,tableRowOdd" rowClasses="tableRowEven,tableRowOdd"
cellpadding="1" cellspacing="1" width="100%">
<h:column >
<hutputText value="#{questions.questionText}" rendered="#{questions.displayType ne 'String'}" />
<hutputText value="#{questions.questionText}" rendered="#{questions.displayType eq 'String'}" styleClass="divheader" style="width: 100%;"/>
</h:column>
<h:column>
<h:graphicImage url="../../images/spacer.gif" width="1%" />
<h:inputText rendered="#{questions.displayType eq 'TextBox'}" id="inputTextid" value="#{questions.defaultAnswerString}"
validator="#{requirementBean.validateInput}" />

<h:selectOneMenu value="#{questions.defaultAnswerInteger}" rendered="#{questions.displayType eq 'DropDown'}"
id="selectOneMenuid" valueChangeListener="#{requirementBean.valueChangeSelectOneMenu}">
<f:selectItems value="#{questions.option}" />
</h:selectOneMenu>

<h:selectManyListbox size="5" value="#{questions.defaultAnswerArray}" rendered="#{questions.displayType eq 'MDropDown'}"
id="selectManyListboxid" valueChangeListener="#{requirementBean.valueChangeSelectManyListbox}" >
<f:selectItems value="#{questions.option}" />
</h:selectManyListbox>

<h:selectOneRadio value="#{questions.defaultAnswerInteger}" rendered="#{questions.displayType eq 'RadioButton'}" id="selectOneRadioid">
<f:selectItems value="#{questions.option}"/>
</h:selectOneRadio>

<h:selectManyCheckbox value="#{questions.defaultAnswerArray}" rendered="#{questions.displayType eq 'CheckBox'}"
id="selectManyCheckboxid" valueChangeListener="#{requirementBean.valueChangeSelectManyCheckbox}">
<f:selectItems value="#{questions.option}" />
</h:selectManyCheckbox>
</h:column>
</h:dataTable>

=========================================================
Here's the java code that is written in the managed bean.
/**
* valueChangeSelectOneMenu
*
* @param ValueChangeEvent evt
*
* puts the selected value of drop down into a List
*/
public void valueChangeSelectOneMenu(ValueChangeEvent evt) {
selectedValueOfDropDown.add((Integer) evt.getNewValue());
}

/**
* valueChangeSelectManyListbox
*
* @param ValueChangeEvent evt
*
* Puts the selected answer which is array of Integer into List
*/
public void valueChangeSelectManyListbox(ValueChangeEvent evt) {
// evt.getNewValue() This comes as array of integer
valueMultipleSelectList.add(evt.getNewValue());
}

/**
* valueChangeSelectManyCheckbox
*
* @param ValueChangeEvent evt
*
* Puts the selected answer which is array of Integer into List
*/
public void valueChangeSelectManyCheckbox(ValueChangeEvent evt) {
valueSelectManyCheckbox.add(evt.getNewValue());
}



Hope this make the things more clear.
Please let me know if things are stil not clear.


Thanks & Regards
Ved
11 years ago
JSF
Hi Experts,
Please be patient in reading the problem as it is a long one.

Im working on a application wherein im using JavaServerFaces in the Web layer.I'm relatively new to the world of JSF and stil playing around with its intecasies.
I have the following UI components h:selectOneMenu,h:selectManyListbox,h:selectOneRadio & h:selectManyCheckbox in the jsp.
These display the various values as drop downs which are selected by the user.
I also have to display the default values as selected in these drop downs and check boxes.
One restriction is that i donot know how many of these components my jsp will have , so i cant create that number of attributes in the managed bean to capture the selected values from the user for each of these components.
Some time i may have two h:selectOneMenu and four h:selectManyListbox and sometime i may have five h:selectManyListbox and two h:selectOneRadio. So the bottomline is that, it can be of any permutaion /combinatins.
So in order to capture the selected values i've used valueChangeListener. All of these componets are binded to a listener i.e its valueChangeListener attribute is been used.
In the method which implement the valueChangeListener , i create a arraylist and stores the selected values in it.This way im storing the selected values.
So when the user submits the form the method implemeting the valuechangelistener is called and the corrosponding arraylist is populated.
I've to display the default value for these components.So in the value attribute of these components i have provided with default
selection.
But now i have ran in to a major bug.I dont know whether it is a discrepancy in the behaviour of valueChangeListener or i have implemented it wrongly.
If we don't change the selected values of the component then it's ValueChangeListener is not called i.e if the user performs a submit without changing the value of any of the component then the ValueChangeListener is not called.
I need couple of help
1)Whether my approach is correct or it is wrong.
2)If the approach is wrong then how do i acheive the following behaviour.
3)How do i capture the changed values as well as the defalut values in this case.

Thanks in advance for any kind of help provided.
Regards
11 years ago
JSF
Hi Experts,
I'm working on an application which is to turned in to a tiles based application using the org.apache.myfaces.tomahawk.application.jsp.JspTilesViewHandlerImpl.
We are using panelNavigation2 and tree2 component and using tomahawk-1.1.3,myfaces-impl-1.1.3 and struts version 1.2.8.
These component works fine when used outside the tiles aplication but when used in a tiles based application panelNavigation2 menu and tree2 is not working at all.
The component is renderdered fine but the there is no action on it...means java script in not getting fired on it....tree node does not expand and the menu does not open.

This is my web.xml
=========================================
<?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" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<description>debug web.xml</description>
<context-param>
<description>Comma separated list of URIs of (additional) faces config files.
(e.g. /WEB-INF/my-config.xml)
See JSF 1.0 PRD2, 10.3.2
Attention: You do not need to put /WEB-INF/faces-config.xml in here.
</description>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml,/WEB-INF/faces-managed-beans.xml,/WEB-INF/faces-navigation.xml</param-value>
</context-param>
<context-param>
<description>State saving method: "client" or "server" (= default)
See JSF Specification 2.5.3</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<description>Only applicable if state saving method is "server" (= default).
Defines the amount (default = 20) of the latest views are stored in session.</description>
<param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
<param-value>20</param-value>
</context-param>
<context-param>
<description>Only applicable if state saving method is "server" (= default).
If true (default) the state will be serialized to a byte stream before it
is written to the session.
If false the state will not be serialized to a byte stream.</description>
<param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>Only applicable if state saving method is "server" (= default) and if
org.apache.myfaces.SERIALIZE_STATE_IN_SESSION is true (= default)
If true (default) the serialized state will be compressed before it
is written to the session. If false the state will not be compressed.</description>
<param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>This parameter tells MyFaces if javascript code should be allowed in the
rendered HTML output.
If javascript is allowed, command_link anchors will have javascript code
that submits the corresponding form.
If javascript is not allowed, the state saving info and nested parameters
will be added as url parameters.
Default: "true"</description>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>If true, rendered HTML code will be formatted, so that it is "human readable".
i.e. additional line separators and whitespace will be written, that do not
influence the HTML code.
Default: "true"</description>
<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>If true, a javascript function will be rendered that is able to restore the
former vertical scroll on every request. Convenient feature if you have pages
with long lists and you do not want the browser page to always jump to the top
if you trigger a link or button action that stays on the same page.
Default: "false"</description>
<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
Validate managed beans and navigation rules.
</description>
<param-name>org.apache.myfaces.validate</param-name>
<param-value>true</param-value>
</context-param>
<!-- Tiles ViewHandler config file -->
<context-param>
<description>Tiles configuration
definition files and a listener need to be defined.
the listener will initialize JspTilesViewHandlerImpl with tiles definitions.
</description>
<param-name>tiles-definitions</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</context-param>

<!--
<context-param>
<description>A class implementing the
org.apache.myfaces.shared.renderkit.html.util.AddResource
interface. It is responsible to
place scripts and css on the right position in your HTML document.
Default: "org.apache.myfaces.shared.renderkit.html.util.DefaultAddResource"</description>
<param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>
<param-value>org.apache.myfaces.component.html.util.StreamingAddResource</param-value>
</context-param>
-->

<filter>
<filter-name>extensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
<init-param>
<description>Set the size limit for uploaded files.
Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB</description>
<param-name>uploadMaxFileSize</param-name>
<param-value>100m</param-value>
</init-param>
<init-param>
<description>Set the threshold size - files
below this limit are stored in memory, files above
this limit are stored on disk.
Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB</description>
<param-name>uploadThresholdSize</param-name>
<param-value>100k</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>/faces/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>SourceCodeServlet</servlet-name>
<servlet-class>org.apache.myfaces.shared_tomahawk.util.servlet.SourceCodeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SourceCodeServlet</servlet-name>
<url-pattern>*.source</url-pattern>
</servlet-mapping>
<servlet>

<servlet-name>TilesServet</servlet-name>
<servlet-class>org.apache.struts.tiles.TilesServlet</servlet-class>
</servlet>

<welcome-file-list>
<welcome-file>userLogin.jsf</welcome-file>
</welcome-file-list>
<!-- for error page with code
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page> -->
</web-app>
========================================================
I'm not able to figure out wht is the problem and im aslo starting to wonder whether jsf and tiles working together seamlessly or not.
Please advice me as to where im going/doing wrong.

Thanks
Ved
11 years ago
JSF
What are the following association mean?

single-valued association
single-ended associations

please clarify these two associations..
thanks
ved