Great. How about adding how you did it to the wiki and pass on your know-how as I'm sure others will be facing the same problem :)


From: Gregg Bolinger [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 28, 2006 3:33 PM
To: MyFaces Discussion
Subject: Re: Design Type Question

New info.  If I place all this code in a function and call that function on document load, it works fine.  So I guess I'll just go that route.

On 6/28/06, Gregg Bolinger <[EMAIL PROTECTED]> wrote:
Alright.  Thanks for the info.  Getting closer.  I have the following being spit out on my page after rendered.

var options = document.getElementById('catSelect').options;
var option = new Option('4', 'Active');
options[options.length] = option;
var option = new Option('69', 'Appreciate');
options[ options.length] = option;
var option = new Option('3', 'Explore');
options[options.length] = option;
var option = new Option('71', 'Habitat');
options[options.length] = option;
var option = new Option('70', 'Indulge');
options[options.length] = option;
var option = new Option('1', 'Locate');
options[options.length] = option;
var option = new Option('2', 'People');
options[options.length] = option;

And I am getting
document.getElementById("catSelect") has no properties error.  I also see this on the rendered HTML:

<select id="catSelect" name="catSelect" size="1"> <option value="0">ALL</option></select>

Which is accurate as to:

<t:selectOneMenu forceId="true" id="catSelect" value="#{ArticleListBean.category}">
     <f:selectItem itemLabel="ALL" itemValue="0" />
</t:selectOneMenu>

Anything jump out?
                   


On 6/28/06, Julian Ray < [EMAIL PROTECTED] > wrote:
No if you use selectOne components which update the backingbean. Your JS should reference the selectOne components via ids - you might have to pass dummy select items but these will get removed then replaced by the JS as it loads. Remember that the page is rendered before its loaded by the browser so the JS will execute after the rendering has been performed.


From: Gregg Bolinger [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 28, 2006 3:05 PM

To: MyFaces Discussion
Subject: Re: Design Type Question

Ok, got it working now. One final question.  If I do this with _javascript_, I am going to have to do all the work of updating the model with the new values since it's client side, correct? 

Maybe this should be my first custom component. Eh? lol.
Thanks for the help.

Gregg

On 6/28/06, Gregg Bolinger <[EMAIL PROTECTED]> wrote:
Scratch that.  I am getting the value. But all the code is escaped. &gt;, &lt; etc.  So it doesn't register correclty.  Trying something else....


On 6/28/06, Gregg Bolinger <[EMAIL PROTECTED]> wrote:
Alright, maybe a stupid question...

For testing I have a property in my backing bean called _javascript_ with getters and setters.  I have initialized _javascript_ with the following:

private String _javascript_ = "<script type=\"text/_javascript_\">function testFunction(){ alert('this is a test'); }</script>";

And then did:

t:outputText value="#{ArticleListBean._javascript_}"/>

But it's not spitting out the code.  Am I doing this wrong?


Thanks.


On 6/28/06, Julian Ray <[EMAIL PROTECTED]> wrote:
Make sure to use forceId on the select items so the JS can find them otherwise you will have to prefix the component ids with "formname:"
 


From: Gregg Bolinger [mailto:[EMAIL PROTECTED] ]
Sent: Wednesday, June 28, 2006 2:31 PM

To: MyFaces Discussion
Subject: Re: Design Type Question

Doh!  Didn't even think about that.  Thanks.

On 6/28/06, Julian Ray <[EMAIL PROTECTED]> wrote:
Couldn't you use a <h:outputText value="#{myBackingBean.....}}  /> and either (a) write out the whole _javascript_ or (b) just write out the array part?
 
 


From: Gregg Bolinger [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 28, 2006 1:38 PM

To: MyFaces Discussion
Subject: Re: Design Type Question

Thanks Julian.  *Unfortunately* I'm well adapt at _javascript_ so I already know how to do that.  What I don't know is how to populate _javascript_ arrays with data from my backing bean.

Aside from a custom component, I'd assume I need to do something like that.

Thanks.

On 6/28/06, Julian Ray <[EMAIL PROTECTED] > wrote:
Here is an example, I have not tested it but have used similar approaches
 
 
 


From: Gregg Bolinger [mailto:[EMAIL PROTECTED] ]
Sent: Wednesday, June 28, 2006 11:45 AM
To: MyFaces Discussion
Subject: Re: Design Type Question

Julian,

Thanks for the suggestions.  How would I go about populating _javascript_ values with data from the backing bean if I were to go with [1]?  Any links with this info?

Thanks.

On 6/28/06, Julian Ray <[EMAIL PROTECTED] > wrote:
Some suggestions
 
[1] Use client-side population of teh drop downs
[2] Use 2 backing beans, 1 for the drop down and 1 for the articles. Lazily load all getters. Use t:saveState to store the filter bean.
[3] Use Ajax


From: Gregg Bolinger [mailto:[EMAIL PROTECTED] ]
Sent: Wednesday, June 28, 2006 10:20 AM
To: MyFaces Discussion
Subject: Design Type Question

This isn't about MyFaces specifically so I apologize but this list is the best JSF resource I know of. ;)

I have a page that contains a list of Articles.  There are also filter criteria to filter the list of Articles.  The article list is a dataTable who's value is a method in the backing bean that returns a list of articles.  Simple enough.  So when the page first loads, I get all the articles.

The problem I am facing is part of the filter is 3 levels of categories.  Category, Sub Category, and a Sub Sub Category.  Each of these is a selectOneMenu and the child catagories depends on the parent category.  So I have valueChangeListeners registered so that when one drop down changes, the child dropdown gets new values.

The problem with this is that when this happens, my method to get the list of articles is called.  But I don't want this to happen until I click the Search button.  So I am just looking for solutions to solve this.

Thanks.








Reply via email to