Anthony Taylor

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

It is a long story, but in a nutshell, I need to be able to get a reference to the object and pass it along to another object for manipulation. According to the rules for the various Phases, I should be able to achieve this. I just don't understand why the values are not set after update model values phase.
15 years ago
JSF
It is a long story, but in a nutshell, I need to be able to get a reference to the object and pass it along to another object for manipulation. According to the rules for the various Phases, I should be able to achieve this. I just don't understand why the values are not set after update model values phase.
15 years ago
JSF
I have been trying to get a reference to my BackingBeans from the PhaseListener with no luck. I tried two different approaches so far. 1) tried to pull the Bean object out of the request. 2) I tried to pull the bean object out with the ELResolver. Both approaches give me the BackingBean, the only problem is that properties of the BackingBean are all null. Unless I am mistaken, shouldn't the properties have values after the Update Model Values phase? If I tried to access the properties from within the bean, through an action, the properties have values. Strange behavior. Could someone shed some light on this problem.
15 years ago
JSF
Here is my dilemma. I have a bean with a save action. I also have a PhaseListener attached to the f:view tag associated with this page. For whatever reason, I need to perform a save before the Invoke Application phase is reached. Now I am using ELResolver to pull and retrieve the Bean at the afterUpdateModelValues phase, i.e. FacesContext oContext = FacesContext.getCurrentInstance();
ELResolver oResolver = oContext.getApplication().getELResolver();
Object oValue = oResolver.getValue(oContext.getELContext(), null, "beanNameAsItAppearsInFacesConfig");. Now I appear to be finding the bean as I am not returning null. However, when I try to access the various properties to retrieve their values, they are all null. This is a backing bean with its properties binded to the page components. I have tried to access the Bean from several of the different phases with the same result. Is there any reason why this would occur? Maybe I am misunderstanding the various phases. Any help would be greatly appreciated. Thanks.
15 years ago
JSF
I am using dojo and jsf together and have run into a bit of a problem with submitting forms. The javascript method dojo.io.bind requires a property called content which will receive an object with parameters for each form's associated fields. As an example, it look something like this content: {formfield1 : value, formfield2 : value}. Now, is there a way in javascript to dynamically generate objects, when I dont know the names or number of properties. My thinking is that I could write a function that will loop through the form and create the corresponding object on the fly. Any examples or suggestions would be greatly appreciated.
With that said, I attached the afterPhase event to my f:view tag for my jsp page. Now I tried one post attached to an event and I tried to just post the form using javascript. Now in both cases it is skipping to Render Response and bypassing the other phases. With what you just mentioned, if I dont trigger the post through an action shouldn't it go through the whole lifecycle if I just post the form instead, as long as there are no validation errors that is.
15 years ago
JSF
I have an action connected to a commandButton and was wondering where in the lifecycle actions occur. It appears as if they run right before render response, though I could be mistaken. Is there a way to have it trigger, say, after UpdateModelValues() phase. When I make the post, the only item that changes is the value of a hidden field, everything else remains the same. For some reason, it seems like the lifecycle is not running its course. What differentiates postback requests from get requests and what factors into the distinction. Basically, I would like for it to go through the complete lifecycle when the post occurs. Any ideas on what I could be doing wrong?
15 years ago
JSF
I have a big problem. I am trying to pass the name of a control as a content parameter to simulate a jsf post with ajax but the components in jsf require a colon. For example, the content property would look like this content: {name1: value1, name2: value2, formName:button: value3}. Is there another way to pass the formName:button name using javascript?
Now when I switched the select widget to a standard html control it works.

here is the jsp page:

<html>
<head>
<title>Dojo: Hello World!</title>

<!-- SECTION 1 -->
<script type="text/javascript" src="js/kstools.js"></script>
<script type="text/javascript" src="js/dojo/dojo.js"></script>
<script type="text/javascript">
dojo.require("dojo.event.*");

// Load Dojo's code relating to widget managing functions
dojo.require("dojo.widget.*");

// Load Dojo's code relating to the Button widget
dojo.require("dojo.widget.Button");

function helloPressed()
{
// Don't forget to replace the value for 'url' with
// the value of appropriate file for your server
// (i.e. 'HelloWorldResponsePOST.asp') for an ASP server
dojo.io.bind({
url: 'HelloWorldResponseGET.jsp',
handler: helloCallback,
formNode: dojo.byId('myForm'),
mimetype: 'text/xml'
});
}



function init()
{
var helloButton = dojo.widget.byId('helloButton');
dojo.event.connect(helloButton, 'onClick', 'helloPressed')
}

dojo.addOnLoad(init);

function helloCallback(type, data, evt)
{
if (type == 'error')
{
alert('Error when retrieving data from the server!');
}
else
{
populateForm(data, document.getElementById('myForm'));
}

}

</script>
</head>

<body>
<button dojoType="Button" widgetId="helloButton" toggle="explode" toggleDuration="250">Hello World!</button>
<br>
<form id="myForm" method="POST">
Please enter your name: <input type="text" name="name" id="testtext">
<br>
<br>
<select class="dojo-ComboBox" style="width: 50px;" name="testcombo" id="testcombo">
<option value="foo">foo</option>
<option value="bar">bar</option>
<option value="baz">baz</option>
<option value="thud">thud</option>
</select>
</form>
<br>
<br>
your response is <span id="textdata"></span>
</body>
</html>


here is the js code:

function populateForm(data, frmObj)
{
var text = '';
var name = '';
var theForm = frmObj;

clearFields(theForm);

for (var i = 0;;i++)
{
if (data.getElementsByTagName('name')[i] == null && data.getElementsByTagName('text')[i] == null)
{
break;
}

name = data.getElementsByTagName('name')[i].childNodes[0].nodeValue;
text = data.getElementsByTagName('text')[i].childNodes[0].nodeValue;

------> THIS IS WHERE THE DOM CAN NOT FIND THE WIDGET <--------
if (document.getElementById(name) != null && document.getElementById(name) != 'undefined')
{
populateByType(document.getElementById(name), text);
}
}
}
I am trying to change the values of some form fields(widgets), using javascript, and I seems as if the javascript form object cannot find the controls. Has anyone else ran into this problem and if so what was your fix. I am using the document.getElementById.
dojo is a framework for doing ajax and widgets. dojotoolkit.org.
I have been trying to implement dojo but I am receiving errors when I retrieve the response. I dont see where the problem lies. Does anyone have any examples of retrieving xml from a jsf page. The type parameter seems to have a value of 'error'. Also, could somene point me in the direction of some good examples of using jsp with dojo? Here is my code:

index.jsp:

<html>
<head>
<title>Dojo: Hello World!</title>

<!-- SECTION 1 -->
<script type="text/javascript" src="js/dojo/dojo.js"></script>
<script type="text/javascript" src="js/dojo/kstools.js"></script>
<script type="text/javascript">
dojo.require("dojo.event.*");

// Load Dojo's code relating to widget managing functions
dojo.require("dojo.widget.*");

// Load Dojo's code relating to the Button widget
dojo.require("dojo.widget.Button");

function helloPressed()
{
// Don't forget to replace the value for 'url' with
// the value of appropriate file for your server
// (i.e. 'HelloWorldResponsePOST.asp') for an ASP server
dojo.io.bind({
url: 'HelloWorldResponseGET.jsp',
handler: helloCallback,
formNode: dojo.byId('myForm'),
mimetype: 'text/xml'
});
}



function init()
{
var helloButton = dojo.widget.byId('helloButton');
dojo.event.connect(helloButton, 'onClick', 'helloPressed')
}

dojo.addOnLoad(init);

function helloCallback(type, data, evt)
{
if (type == 'error')
{
alert('Error when retrieving data from the server!');
}
else
{
//alert(data);
var root = data.getElementsByTagName('ksdata').item(0);
var child = root.childNodes.item(0);
dojo.byId('textdata').innerHTML = child.childNodes.item(0);
//populateForm(data);
}
}


</script>
</head>

<body>
<button dojoType="Button" widgetId="helloButton" toggle="explode" toggleDuration="250">Hello World!</button>
<br>
<form id="myForm" method="POST">
Please enter your name: <input type="text" name="name">
</form>
<br>
<select dojoType="combobox">
<option value="foo">foo</option>
<option value="bar">bar</option>
<option value="baz">baz</option>
<option value="thud">thud</option>
</select>
<br>
your response is <span id="textdata"></span>
</body>
</html>


index.jsp:


<%
/*
' HelloWorldResponseGET.jsp
' --------
'
' Print the name that is passed in the
' 'name' GET parameter in a sentence
*/

response.setContentType("text/xml");
%>
<%=
"<ksdata>" +
"<message>" +
"<type>error</type>" +
"<text>You entered an invalid username.</text>" +
"</message>" +
"<values>" +
"<value>" +
"<name>Control1</name>" +
"<text>Text1</text>" +
"</value>" +
"<value>" +
"<name>Control2</name>" +
"<text>Text2</text>" +
"</value>" +
"<value>" +
"<name>Control3</name>" +
"<text>Text3</text>" +
"</value>" +
"<value>" +
"<name>Control4</name>" +
"<text>Text4</text>" +
"</value>" +
"</values>" +
"</ksdata>"
%>
I seem to be confused when it comes to form population. I try very hard to limit the amount of session beans I use to storing user login information, etc. For the most part, I prefer to use client-side viewstate over session beans. I know there are cases where the latter is necessary. Now for my dilemma, I still dont see how to populate a bean tied to a particular view using the viewstate scenario. As an example, suppose I have a page that has a datagrid where a user can click a link which is connected to an id field of a table on the backend database, which will then take the user to a page where they can get detailed information about the particular record they selected from the previous page. I know that backing beans also hold the actions to be performed for button click, link clicks, etc. but this seems to be a different kind of interaction because it spans across two different pages. To me, it seems like the backing bean would have to somehow receive the id of the particular record and populate itself, as oppose to the previous page being responsible for this. Once again, I would like to limit the amount of session beans I use. Where should this loading of the backing bean take place and how does this affect the view? Any examples and explanations would be greatly appreciated?
15 years ago
JSF
I am trying to understand how to maintain viewstate between the client and the server when the viewstate is stored on the client. Since the page is initially loaded once, I think I would have to somehow pass the viewstate to the server on each request using javascript. Then, I would have to somehow receive the viewstate from the server and reset the viewstate on the client. Am I thinking correctly on this? Can anyone provide me with examples of how this should be done?
15 years ago
JSF
I seem to be a little confused about the ordering for a JSF Backing Bean. I know that I have the getters and the setters for the different methods that correspond to the different components on the page. Now the confusing part, if I am trying to incorporate ajax into the mix .. how or where do I add the code to perform the server-side processing for this Backing Bean. As an example, suppose I have a page connected to a backing bean. And lets suppose that I would like ajax to validate as the user typed information into the textbox component. As the request is sent to the "action" for this page .. I would imagine the logic for determining if an error occured and sending the appropriate message back to the user would have to go somewhere in the backing bean so it could get called. I know usually this logic would go into an event that is connected to a button or other component on the page, but this seems to be a little bit different for ajax based apps. Should this all occur in the constructor for the backing bean or is there another place this code should go? Any examples or code snippets would be greatly appreciated as I am thoroughly confused on this one.
15 years ago
JSF