How to get event when custom stencil value changed?

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member

How to get event when custom stencil value changed?

Jump to solution

I am using stencil in form . So i created  UI to replace stencil in ADF Form.

FormService.formFieldValueChanged method caling when form input value changed .But Its not calling when custom Stencil value changed . How can i get event when  Value of custom Stencil changed  in ADF Form ?

Ex : Custom Stencil replace with input box  . When Input box value change that time i want to generate event  same like adf form input box value change  that time this event will call

FormService.formFieldValueChanged

export class TaskAddCommentComponent extends WidgetComponent {

}

export class TaskDetailComponent implements OnInit, OnDestroy, AfterViewInit {

this.formRenderingService.setComponentTypeResolver('muraai_comments', () => TaskAddCommentComponent, true);

 

IN this component  i want to get event when stencil input box value changed. Is It possible ?

}

1 Solution

Accepted Solutions
Highlighted
Alfresco Employee

Re: How to get event when custom stencil value changed?

Jump to solution

Yes, that 'formFieldValueChanged' is raised on each field value change as the name of the event states.

You can listen to this event from any place. If you want to "emit" this event, you need to call "formFieldValueChanged.emit(...)". Please refer to documentation or source code.

View solution in original post

7 Replies
Highlighted
Alfresco Employee

Re: How to get event when custom stencil value changed?

Jump to solution

Your custom stencil needs to import the FormService and invoke corresponding events. See alfresco-ng2-components/form.service.ts at development · Alfresco/alfresco-ng2-components · GitHub 

Highlighted
Active Member

Re: How to get event when custom stencil  value changed?

Jump to solution

Hi Denys,

 I have to  import  form service in  stencil custom component . If  I  update any other form field value from this component then it will reflect.

ex. 

 Inside custom Stencil component 

FormService.formFieldValueChanged  this event will call and i will get all field in custom stencil  i can update . Is it correct ?

FormService.formFieldValueChanged.subscribe ((e :FormFieldEvent) {

const fields = e.form.getFormFields();
const name = fields.find(f => f.id === 'name');
name.value ="dharmraj"

});

Highlighted
Alfresco Employee

Re: How to get event when custom stencil value changed?

Jump to solution

Yes, that 'formFieldValueChanged' is raised on each field value change as the name of the event states.

You can listen to this event from any place. If you want to "emit" this event, you need to call "formFieldValueChanged.emit(...)". Please refer to documentation or source code.

View solution in original post

Highlighted
Active Member

Re: How to get event when custom stencil value changed?

Jump to solution

Hi Denys,

formFieldValueChanged event  is not calling for custom stencil component.

export class TaskAddCommentComponent extends WidgetComponent {

 ngOnInit(): void {

        this.formService.formFieldValueChanged.subscribe(
       ( e: FormFieldEvent ) => {
       console.log(e);

     })

 }

This code is not working . 

}

export class TaskDetailComponent implements OnInit, OnDestroy, AfterViewInit {

 

this.formRenderingService.setComponentTypeResolver('muraai_comments', () => TaskAddCommentComponent, true);

ngOnInit(): void {

        this.formService.formFieldValueChanged.subscribe(
       ( e: FormFieldEvent ) => {
       console.log(e);

     })

 }

 Here code is working. But when custom  stencil component  input box value is changing that time its not calling

}

Highlighted
Alfresco Employee

Re: How to get event when custom stencil value changed?

Jump to solution

As I answered above, you need to raise (emit) event yourself from the custom stencil. It is not going to magically raise event itself

Highlighted
Active Member

Re: How to get event when custom stencil  value changed?

Jump to solution

Hi Denys,

 I'll have to emit event from custom stencil component to the main component using Angular 4.  There is no ADF Form event   Is It correct ?

Highlighted
Alfresco Employee

Re: How to get event when custom stencil value changed?

Jump to solution

Yes.