Hello Ivy Team

I have some questions concerning the access of Components data, methods and updating in ivy-jsf.
Some points might not been implemented yet so consider these also as ideas or wishes.

In my example there is a main dialog which implements 2 components:

<ic:ch.itpoint.mms.care.ItemEdit startMethod="startNew" callback="#{logic}" />
<ic:ch.itpoint.mms.show.ItemList startMethod="start" />

There are two targets I want to reach:

  1. Creating a Item or editing it should update the ItemList
  2. Selecting an Item in the List should open the Object in the Item-Editor

One restriction is, that all that should be build up like described with components. Saving events will be handled first in the component, then in the main-page. Another might be to preferably stay away from self made javascripts.

I achieved, that I can save the Item and call a method (itemSaved()) via the callback on the main-page at the same time:

<p:commandButton value="#{ivy.cms.co('/lables/save')} - Callback"
actionListener="#{logic.saveItem}" action="#{cc.attrs.callback.itemSaved}" ajax="true" icon="ui-icon-disk" update="itemForm,:j_id_s:itemsListeForm" />

That's allready something, but I didn't find any way to access the List-Component.
In the end I would see these possibilities:

  1. Having access to components methods / events, which also provoke an update in the view.
  2. Having access to components data from main page. And some kind of dataChangeListener to update the view.

Two possible solutions I see:

  1. An object of the compoenent in jsf (with possible access in the logic)
  2. Same object in the logic (same as ULC-components)

An Update could exceptionally be fired by the update-Attribute :j_id_s:itemsListeForm in the brother-component (I don't know if it would work)

Thank you for your support!

Greetings
Alexis Suter

asked 19.02.2014 at 10:21

Alexis's gravatar image

Alexis
(suspended)
accept rate: 66%


Hello Alexis,

In the interface of your component you can set the input and output arguments.

In the output arguments you set the attributs you need on the parent component (value1, value2).

In the input arguments you set the attributs you need on the child component (value3). Now you can bind the attribut to the data class of the parent component like this:

<ic:ch.test value1=#{data.value1} value2=#{data.value2} value3=#{data.value3} />

Every time the logic of the child component hits a endpoint you can update the form and you have the new values.

To update something from the parentComponent in the ChildComponent you can use this code snippet

update="#{cc.id}:form"

When I need a form in the childcomponent and update it with some commands on the parentComponent I always declare the form before I include the component

<h:form id="form4Component">
<ic:ch.test value1=#{data.value1} value2=#{data.value2} value3=#{data.value3} />
</h:form>

hint: if you want to avoid ids made by primfaces j_id_s:itemsListeForm you can set prependId=false on the form.

regards Raphael

link

answered 19.02.2014 at 15:40

Raphael%20B%C3%BCrgin's gravatar image

Raphael Bürgin
(suspended)
accept rate: 55%

edited 20.02.2014 at 09:05

Hello Raphael Thanks a lot for your answer! It brought me some steps toward the target. There is P(parent), A and B. B surrounded with form4Component. Data of B doesn't get updated, although data is updated in P and the gui has been updated. Same result after manualy invoking an event in B.

(19.02.2014 at 17:11) Alexis Alexis's gravatar image

Maybe a f:event will help

<f:event type="preRenderComponent" listener="#{bean or logic to update the values}" />

<f:event type="preRenderView" listener="#{bean or logic to update the values}" />

Every time you render/update the Component or View this event will be fired

(20.02.2014 at 14:42) Raphael Bürgin Raphael%20B%C3%BCrgin's gravatar image
1

Thank you a lot Raphael!
This simplifies the solution a lot! There is less work to do.
In the mainframe I put the Component into a p:panel, so I can keep the form inside the Component.
The selected Item I put into a Bean, cause Data in Logic won't be updated from Main / other Component.
Greetings

(25.02.2014 at 14:46) Alexis Alexis's gravatar image

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×79
×58
×7
×1

Asked: 19.02.2014 at 10:21

Seen: 7,159 times

Last updated: 25.02.2014 at 14:46