JSF websocket update viewScope












-2















I have a bean named sampleBean scoped by viewScope .

this bean load some data from database (MySQL) .

my problem is some records shared between users .

now maybe [USER A] delete that shared record and i want to update view of other users .



I can not change scope to ApplicationScope because all records shared to all users .



How can fix this problem ?
Note : I read this post but can not understand how can fix this problem .
Note : I use Liberty 18.0.0.4 by JavaEE 8 (webProfile)










share|improve this question




















  • 1





    Changing the scope to @ApplicationScoped would not solve anything. As the post you are linking to discusses, you can use a f:websocket to accomplish your above requirement. This tag requires JSF 2.3. To get it working with Liberty, please refer to ibm.com/support/knowledgecenter/en/SSEQTP_liberty/…. Also, if you could provide us with a Minimal, Complete, and Verifiable example that covers your case (maybe with a backing bean just providing random data), we could provide you with an example in your specific case.

    – Adam Waldenberg
    Jan 19 at 7:09











  • I fixed problem , bad used cased "@Observer" in JSF .

    – mah454
    Jan 19 at 8:10






  • 1





    @mah454: This question is in its current state useless for others since it is not clear what the code (in Minimal, Complete, and Verifiable example flavour) was and what the change should be.Can you improve it and create a good corresponding answer?

    – Kukeltje
    Jan 19 at 10:07













  • @Kukeltje , I answered to my question , please vote up :D

    – mah454
    Jan 20 at 12:47











  • Sorry, no, voted down. See the comment. Answer is not the right way to do it (sort of wrong even) and there is no corresponding code in the question so it is hard for others to see what was wrong

    – Kukeltje
    Jan 21 at 7:53
















-2















I have a bean named sampleBean scoped by viewScope .

this bean load some data from database (MySQL) .

my problem is some records shared between users .

now maybe [USER A] delete that shared record and i want to update view of other users .



I can not change scope to ApplicationScope because all records shared to all users .



How can fix this problem ?
Note : I read this post but can not understand how can fix this problem .
Note : I use Liberty 18.0.0.4 by JavaEE 8 (webProfile)










share|improve this question




















  • 1





    Changing the scope to @ApplicationScoped would not solve anything. As the post you are linking to discusses, you can use a f:websocket to accomplish your above requirement. This tag requires JSF 2.3. To get it working with Liberty, please refer to ibm.com/support/knowledgecenter/en/SSEQTP_liberty/…. Also, if you could provide us with a Minimal, Complete, and Verifiable example that covers your case (maybe with a backing bean just providing random data), we could provide you with an example in your specific case.

    – Adam Waldenberg
    Jan 19 at 7:09











  • I fixed problem , bad used cased "@Observer" in JSF .

    – mah454
    Jan 19 at 8:10






  • 1





    @mah454: This question is in its current state useless for others since it is not clear what the code (in Minimal, Complete, and Verifiable example flavour) was and what the change should be.Can you improve it and create a good corresponding answer?

    – Kukeltje
    Jan 19 at 10:07













  • @Kukeltje , I answered to my question , please vote up :D

    – mah454
    Jan 20 at 12:47











  • Sorry, no, voted down. See the comment. Answer is not the right way to do it (sort of wrong even) and there is no corresponding code in the question so it is hard for others to see what was wrong

    – Kukeltje
    Jan 21 at 7:53














-2












-2








-2








I have a bean named sampleBean scoped by viewScope .

this bean load some data from database (MySQL) .

my problem is some records shared between users .

now maybe [USER A] delete that shared record and i want to update view of other users .



I can not change scope to ApplicationScope because all records shared to all users .



How can fix this problem ?
Note : I read this post but can not understand how can fix this problem .
Note : I use Liberty 18.0.0.4 by JavaEE 8 (webProfile)










share|improve this question
















I have a bean named sampleBean scoped by viewScope .

this bean load some data from database (MySQL) .

my problem is some records shared between users .

now maybe [USER A] delete that shared record and i want to update view of other users .



I can not change scope to ApplicationScope because all records shared to all users .



How can fix this problem ?
Note : I read this post but can not understand how can fix this problem .
Note : I use Liberty 18.0.0.4 by JavaEE 8 (webProfile)







jsf jsf-2.3






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 20 at 12:39







mah454

















asked Jan 19 at 6:55









mah454mah454

499415




499415








  • 1





    Changing the scope to @ApplicationScoped would not solve anything. As the post you are linking to discusses, you can use a f:websocket to accomplish your above requirement. This tag requires JSF 2.3. To get it working with Liberty, please refer to ibm.com/support/knowledgecenter/en/SSEQTP_liberty/…. Also, if you could provide us with a Minimal, Complete, and Verifiable example that covers your case (maybe with a backing bean just providing random data), we could provide you with an example in your specific case.

    – Adam Waldenberg
    Jan 19 at 7:09











  • I fixed problem , bad used cased "@Observer" in JSF .

    – mah454
    Jan 19 at 8:10






  • 1





    @mah454: This question is in its current state useless for others since it is not clear what the code (in Minimal, Complete, and Verifiable example flavour) was and what the change should be.Can you improve it and create a good corresponding answer?

    – Kukeltje
    Jan 19 at 10:07













  • @Kukeltje , I answered to my question , please vote up :D

    – mah454
    Jan 20 at 12:47











  • Sorry, no, voted down. See the comment. Answer is not the right way to do it (sort of wrong even) and there is no corresponding code in the question so it is hard for others to see what was wrong

    – Kukeltje
    Jan 21 at 7:53














  • 1





    Changing the scope to @ApplicationScoped would not solve anything. As the post you are linking to discusses, you can use a f:websocket to accomplish your above requirement. This tag requires JSF 2.3. To get it working with Liberty, please refer to ibm.com/support/knowledgecenter/en/SSEQTP_liberty/…. Also, if you could provide us with a Minimal, Complete, and Verifiable example that covers your case (maybe with a backing bean just providing random data), we could provide you with an example in your specific case.

    – Adam Waldenberg
    Jan 19 at 7:09











  • I fixed problem , bad used cased "@Observer" in JSF .

    – mah454
    Jan 19 at 8:10






  • 1





    @mah454: This question is in its current state useless for others since it is not clear what the code (in Minimal, Complete, and Verifiable example flavour) was and what the change should be.Can you improve it and create a good corresponding answer?

    – Kukeltje
    Jan 19 at 10:07













  • @Kukeltje , I answered to my question , please vote up :D

    – mah454
    Jan 20 at 12:47











  • Sorry, no, voted down. See the comment. Answer is not the right way to do it (sort of wrong even) and there is no corresponding code in the question so it is hard for others to see what was wrong

    – Kukeltje
    Jan 21 at 7:53








1




1





Changing the scope to @ApplicationScoped would not solve anything. As the post you are linking to discusses, you can use a f:websocket to accomplish your above requirement. This tag requires JSF 2.3. To get it working with Liberty, please refer to ibm.com/support/knowledgecenter/en/SSEQTP_liberty/…. Also, if you could provide us with a Minimal, Complete, and Verifiable example that covers your case (maybe with a backing bean just providing random data), we could provide you with an example in your specific case.

– Adam Waldenberg
Jan 19 at 7:09





Changing the scope to @ApplicationScoped would not solve anything. As the post you are linking to discusses, you can use a f:websocket to accomplish your above requirement. This tag requires JSF 2.3. To get it working with Liberty, please refer to ibm.com/support/knowledgecenter/en/SSEQTP_liberty/…. Also, if you could provide us with a Minimal, Complete, and Verifiable example that covers your case (maybe with a backing bean just providing random data), we could provide you with an example in your specific case.

– Adam Waldenberg
Jan 19 at 7:09













I fixed problem , bad used cased "@Observer" in JSF .

– mah454
Jan 19 at 8:10





I fixed problem , bad used cased "@Observer" in JSF .

– mah454
Jan 19 at 8:10




1




1





@mah454: This question is in its current state useless for others since it is not clear what the code (in Minimal, Complete, and Verifiable example flavour) was and what the change should be.Can you improve it and create a good corresponding answer?

– Kukeltje
Jan 19 at 10:07







@mah454: This question is in its current state useless for others since it is not clear what the code (in Minimal, Complete, and Verifiable example flavour) was and what the change should be.Can you improve it and create a good corresponding answer?

– Kukeltje
Jan 19 at 10:07















@Kukeltje , I answered to my question , please vote up :D

– mah454
Jan 20 at 12:47





@Kukeltje , I answered to my question , please vote up :D

– mah454
Jan 20 at 12:47













Sorry, no, voted down. See the comment. Answer is not the right way to do it (sort of wrong even) and there is no corresponding code in the question so it is hard for others to see what was wrong

– Kukeltje
Jan 21 at 7:53





Sorry, no, voted down. See the comment. Answer is not the right way to do it (sort of wrong even) and there is no corresponding code in the question so it is hard for others to see what was wrong

– Kukeltje
Jan 21 at 7:53












1 Answer
1






active

oldest

votes


















-1














I fixed problem by this simple code . (I shared this code for you)



public class Information {
private String name ;
private String family ;

// constructor
// Getter & Setter
// override equal and hashCode

}


This is a simple service . (I simulated database on this class)



@Stateless
public class InformationService {

private static final List<Information> db = new ArrayList<>();

@Inject
@Push(channel = "infoChannel")
PushContext push;

@PostConstruct
public void init() {
Information userA = new Information("John", "Vankate");
Information userB = new Information("Julius", "Sampao");
db.add(userA);
db.add(userB);
}

public void remove(Information info) {
db.remove(info);
push.send("deleteInfo");
}

public List<Information> findAll() {
return db;
}
}


and simple JaxRs resources :



@Path("/info")
@RequestScoped
public class InformationResources {

@EJB
private InformationService informationService;


@Path("/delete")
@POST
@Consumes("application/json")
public String send(Information information) {
informationService.remove(information);
return "Receive : " + information;
}
}


Now Start JSF :



@Named
@ViewScoped
public class InformationBean implements Serializable {

private Information info ;
private List<Information> informationList ;

@EJB
private InformationService informationService ;


@PostConstruct
public void init() {
informationList = informationService.findAll();
info = new Information() ;
}

public void deleteInformation() {
informationService.remove(info);
}

public Information getInfo() {
return info;
}

public void setInfo(Information info) {
this.info = info;
}

public List<Information> getInformationList() {
return informationList;
}

public void setInformationList(List<Information> informationList) {
this.informationList = informationList;
}
}


and xhtml :



<h:body>
<p:dataTable value="#{informationBean.informationList}" var="info" id="infoTable">
<p:column rowHeader="name">
<h:outputText value="#{info.name}"/>
</p:column>
<p:column rowHeader="family">
<h:outputText value="#{info.family}"/>
</p:column>
<p:column rowHeader="action">
<h:form>
<p:commandButton value="Delete" action="#{informationBean.deleteInformation}">
<f:setPropertyActionListener value="#{info}" target="#{informationBean.info}"/>
</p:commandButton>
</h:form>
</p:column>
</p:dataTable>
<hr/>
<f:websocket channel="infoChannel">
<p:ajax event="deleteInfo" update="infoTable"/>
</f:websocket>
</h:body>


I already thought , PushContext must implemented on JSF beans , Now I understand can implement that in service or business logic layer .

Now you can remove information from JaxRs (Rest API) and record removed from p:dataTable without refresh page .
Note : this example use @ViewScoped






share|improve this answer


























  • It is bad practice to add front-end technology (Push) in backend services. The link you posted contains the info to do it right and it works (I use that all the time) And since you did not post what you tried before we cannot help and effectively this Q/A is sort of useless

    – Kukeltje
    Jan 21 at 7:53











  • How do you update view if request received from webservice (Rest or soap)?

    – mah454
    Jan 21 at 19:53






  • 1





    The response should come from A service. The implementation of tbat service should be hidden from calling or depending services. For callback to the caller use an observer ;ike posted in the link

    – Kukeltje
    Jan 21 at 21:59











  • @Kukeltje "@Observer" not working with viewScoped bean . How can fix this problem ?

    – mah454
    Jan 24 at 9:19











  • How is it not working with a viewscoped bean? And please make an Minimal, Complete, and Verifiable example and do you actually need the 'push' related bean to be a viewsoped bean?

    – Kukeltje
    Jan 24 at 10:07













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54264788%2fjsf-websocket-update-viewscope%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









-1














I fixed problem by this simple code . (I shared this code for you)



public class Information {
private String name ;
private String family ;

// constructor
// Getter & Setter
// override equal and hashCode

}


This is a simple service . (I simulated database on this class)



@Stateless
public class InformationService {

private static final List<Information> db = new ArrayList<>();

@Inject
@Push(channel = "infoChannel")
PushContext push;

@PostConstruct
public void init() {
Information userA = new Information("John", "Vankate");
Information userB = new Information("Julius", "Sampao");
db.add(userA);
db.add(userB);
}

public void remove(Information info) {
db.remove(info);
push.send("deleteInfo");
}

public List<Information> findAll() {
return db;
}
}


and simple JaxRs resources :



@Path("/info")
@RequestScoped
public class InformationResources {

@EJB
private InformationService informationService;


@Path("/delete")
@POST
@Consumes("application/json")
public String send(Information information) {
informationService.remove(information);
return "Receive : " + information;
}
}


Now Start JSF :



@Named
@ViewScoped
public class InformationBean implements Serializable {

private Information info ;
private List<Information> informationList ;

@EJB
private InformationService informationService ;


@PostConstruct
public void init() {
informationList = informationService.findAll();
info = new Information() ;
}

public void deleteInformation() {
informationService.remove(info);
}

public Information getInfo() {
return info;
}

public void setInfo(Information info) {
this.info = info;
}

public List<Information> getInformationList() {
return informationList;
}

public void setInformationList(List<Information> informationList) {
this.informationList = informationList;
}
}


and xhtml :



<h:body>
<p:dataTable value="#{informationBean.informationList}" var="info" id="infoTable">
<p:column rowHeader="name">
<h:outputText value="#{info.name}"/>
</p:column>
<p:column rowHeader="family">
<h:outputText value="#{info.family}"/>
</p:column>
<p:column rowHeader="action">
<h:form>
<p:commandButton value="Delete" action="#{informationBean.deleteInformation}">
<f:setPropertyActionListener value="#{info}" target="#{informationBean.info}"/>
</p:commandButton>
</h:form>
</p:column>
</p:dataTable>
<hr/>
<f:websocket channel="infoChannel">
<p:ajax event="deleteInfo" update="infoTable"/>
</f:websocket>
</h:body>


I already thought , PushContext must implemented on JSF beans , Now I understand can implement that in service or business logic layer .

Now you can remove information from JaxRs (Rest API) and record removed from p:dataTable without refresh page .
Note : this example use @ViewScoped






share|improve this answer


























  • It is bad practice to add front-end technology (Push) in backend services. The link you posted contains the info to do it right and it works (I use that all the time) And since you did not post what you tried before we cannot help and effectively this Q/A is sort of useless

    – Kukeltje
    Jan 21 at 7:53











  • How do you update view if request received from webservice (Rest or soap)?

    – mah454
    Jan 21 at 19:53






  • 1





    The response should come from A service. The implementation of tbat service should be hidden from calling or depending services. For callback to the caller use an observer ;ike posted in the link

    – Kukeltje
    Jan 21 at 21:59











  • @Kukeltje "@Observer" not working with viewScoped bean . How can fix this problem ?

    – mah454
    Jan 24 at 9:19











  • How is it not working with a viewscoped bean? And please make an Minimal, Complete, and Verifiable example and do you actually need the 'push' related bean to be a viewsoped bean?

    – Kukeltje
    Jan 24 at 10:07


















-1














I fixed problem by this simple code . (I shared this code for you)



public class Information {
private String name ;
private String family ;

// constructor
// Getter & Setter
// override equal and hashCode

}


This is a simple service . (I simulated database on this class)



@Stateless
public class InformationService {

private static final List<Information> db = new ArrayList<>();

@Inject
@Push(channel = "infoChannel")
PushContext push;

@PostConstruct
public void init() {
Information userA = new Information("John", "Vankate");
Information userB = new Information("Julius", "Sampao");
db.add(userA);
db.add(userB);
}

public void remove(Information info) {
db.remove(info);
push.send("deleteInfo");
}

public List<Information> findAll() {
return db;
}
}


and simple JaxRs resources :



@Path("/info")
@RequestScoped
public class InformationResources {

@EJB
private InformationService informationService;


@Path("/delete")
@POST
@Consumes("application/json")
public String send(Information information) {
informationService.remove(information);
return "Receive : " + information;
}
}


Now Start JSF :



@Named
@ViewScoped
public class InformationBean implements Serializable {

private Information info ;
private List<Information> informationList ;

@EJB
private InformationService informationService ;


@PostConstruct
public void init() {
informationList = informationService.findAll();
info = new Information() ;
}

public void deleteInformation() {
informationService.remove(info);
}

public Information getInfo() {
return info;
}

public void setInfo(Information info) {
this.info = info;
}

public List<Information> getInformationList() {
return informationList;
}

public void setInformationList(List<Information> informationList) {
this.informationList = informationList;
}
}


and xhtml :



<h:body>
<p:dataTable value="#{informationBean.informationList}" var="info" id="infoTable">
<p:column rowHeader="name">
<h:outputText value="#{info.name}"/>
</p:column>
<p:column rowHeader="family">
<h:outputText value="#{info.family}"/>
</p:column>
<p:column rowHeader="action">
<h:form>
<p:commandButton value="Delete" action="#{informationBean.deleteInformation}">
<f:setPropertyActionListener value="#{info}" target="#{informationBean.info}"/>
</p:commandButton>
</h:form>
</p:column>
</p:dataTable>
<hr/>
<f:websocket channel="infoChannel">
<p:ajax event="deleteInfo" update="infoTable"/>
</f:websocket>
</h:body>


I already thought , PushContext must implemented on JSF beans , Now I understand can implement that in service or business logic layer .

Now you can remove information from JaxRs (Rest API) and record removed from p:dataTable without refresh page .
Note : this example use @ViewScoped






share|improve this answer


























  • It is bad practice to add front-end technology (Push) in backend services. The link you posted contains the info to do it right and it works (I use that all the time) And since you did not post what you tried before we cannot help and effectively this Q/A is sort of useless

    – Kukeltje
    Jan 21 at 7:53











  • How do you update view if request received from webservice (Rest or soap)?

    – mah454
    Jan 21 at 19:53






  • 1





    The response should come from A service. The implementation of tbat service should be hidden from calling or depending services. For callback to the caller use an observer ;ike posted in the link

    – Kukeltje
    Jan 21 at 21:59











  • @Kukeltje "@Observer" not working with viewScoped bean . How can fix this problem ?

    – mah454
    Jan 24 at 9:19











  • How is it not working with a viewscoped bean? And please make an Minimal, Complete, and Verifiable example and do you actually need the 'push' related bean to be a viewsoped bean?

    – Kukeltje
    Jan 24 at 10:07
















-1












-1








-1







I fixed problem by this simple code . (I shared this code for you)



public class Information {
private String name ;
private String family ;

// constructor
// Getter & Setter
// override equal and hashCode

}


This is a simple service . (I simulated database on this class)



@Stateless
public class InformationService {

private static final List<Information> db = new ArrayList<>();

@Inject
@Push(channel = "infoChannel")
PushContext push;

@PostConstruct
public void init() {
Information userA = new Information("John", "Vankate");
Information userB = new Information("Julius", "Sampao");
db.add(userA);
db.add(userB);
}

public void remove(Information info) {
db.remove(info);
push.send("deleteInfo");
}

public List<Information> findAll() {
return db;
}
}


and simple JaxRs resources :



@Path("/info")
@RequestScoped
public class InformationResources {

@EJB
private InformationService informationService;


@Path("/delete")
@POST
@Consumes("application/json")
public String send(Information information) {
informationService.remove(information);
return "Receive : " + information;
}
}


Now Start JSF :



@Named
@ViewScoped
public class InformationBean implements Serializable {

private Information info ;
private List<Information> informationList ;

@EJB
private InformationService informationService ;


@PostConstruct
public void init() {
informationList = informationService.findAll();
info = new Information() ;
}

public void deleteInformation() {
informationService.remove(info);
}

public Information getInfo() {
return info;
}

public void setInfo(Information info) {
this.info = info;
}

public List<Information> getInformationList() {
return informationList;
}

public void setInformationList(List<Information> informationList) {
this.informationList = informationList;
}
}


and xhtml :



<h:body>
<p:dataTable value="#{informationBean.informationList}" var="info" id="infoTable">
<p:column rowHeader="name">
<h:outputText value="#{info.name}"/>
</p:column>
<p:column rowHeader="family">
<h:outputText value="#{info.family}"/>
</p:column>
<p:column rowHeader="action">
<h:form>
<p:commandButton value="Delete" action="#{informationBean.deleteInformation}">
<f:setPropertyActionListener value="#{info}" target="#{informationBean.info}"/>
</p:commandButton>
</h:form>
</p:column>
</p:dataTable>
<hr/>
<f:websocket channel="infoChannel">
<p:ajax event="deleteInfo" update="infoTable"/>
</f:websocket>
</h:body>


I already thought , PushContext must implemented on JSF beans , Now I understand can implement that in service or business logic layer .

Now you can remove information from JaxRs (Rest API) and record removed from p:dataTable without refresh page .
Note : this example use @ViewScoped






share|improve this answer















I fixed problem by this simple code . (I shared this code for you)



public class Information {
private String name ;
private String family ;

// constructor
// Getter & Setter
// override equal and hashCode

}


This is a simple service . (I simulated database on this class)



@Stateless
public class InformationService {

private static final List<Information> db = new ArrayList<>();

@Inject
@Push(channel = "infoChannel")
PushContext push;

@PostConstruct
public void init() {
Information userA = new Information("John", "Vankate");
Information userB = new Information("Julius", "Sampao");
db.add(userA);
db.add(userB);
}

public void remove(Information info) {
db.remove(info);
push.send("deleteInfo");
}

public List<Information> findAll() {
return db;
}
}


and simple JaxRs resources :



@Path("/info")
@RequestScoped
public class InformationResources {

@EJB
private InformationService informationService;


@Path("/delete")
@POST
@Consumes("application/json")
public String send(Information information) {
informationService.remove(information);
return "Receive : " + information;
}
}


Now Start JSF :



@Named
@ViewScoped
public class InformationBean implements Serializable {

private Information info ;
private List<Information> informationList ;

@EJB
private InformationService informationService ;


@PostConstruct
public void init() {
informationList = informationService.findAll();
info = new Information() ;
}

public void deleteInformation() {
informationService.remove(info);
}

public Information getInfo() {
return info;
}

public void setInfo(Information info) {
this.info = info;
}

public List<Information> getInformationList() {
return informationList;
}

public void setInformationList(List<Information> informationList) {
this.informationList = informationList;
}
}


and xhtml :



<h:body>
<p:dataTable value="#{informationBean.informationList}" var="info" id="infoTable">
<p:column rowHeader="name">
<h:outputText value="#{info.name}"/>
</p:column>
<p:column rowHeader="family">
<h:outputText value="#{info.family}"/>
</p:column>
<p:column rowHeader="action">
<h:form>
<p:commandButton value="Delete" action="#{informationBean.deleteInformation}">
<f:setPropertyActionListener value="#{info}" target="#{informationBean.info}"/>
</p:commandButton>
</h:form>
</p:column>
</p:dataTable>
<hr/>
<f:websocket channel="infoChannel">
<p:ajax event="deleteInfo" update="infoTable"/>
</f:websocket>
</h:body>


I already thought , PushContext must implemented on JSF beans , Now I understand can implement that in service or business logic layer .

Now you can remove information from JaxRs (Rest API) and record removed from p:dataTable without refresh page .
Note : this example use @ViewScoped







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 20 at 12:52

























answered Jan 20 at 12:42









mah454mah454

499415




499415













  • It is bad practice to add front-end technology (Push) in backend services. The link you posted contains the info to do it right and it works (I use that all the time) And since you did not post what you tried before we cannot help and effectively this Q/A is sort of useless

    – Kukeltje
    Jan 21 at 7:53











  • How do you update view if request received from webservice (Rest or soap)?

    – mah454
    Jan 21 at 19:53






  • 1





    The response should come from A service. The implementation of tbat service should be hidden from calling or depending services. For callback to the caller use an observer ;ike posted in the link

    – Kukeltje
    Jan 21 at 21:59











  • @Kukeltje "@Observer" not working with viewScoped bean . How can fix this problem ?

    – mah454
    Jan 24 at 9:19











  • How is it not working with a viewscoped bean? And please make an Minimal, Complete, and Verifiable example and do you actually need the 'push' related bean to be a viewsoped bean?

    – Kukeltje
    Jan 24 at 10:07





















  • It is bad practice to add front-end technology (Push) in backend services. The link you posted contains the info to do it right and it works (I use that all the time) And since you did not post what you tried before we cannot help and effectively this Q/A is sort of useless

    – Kukeltje
    Jan 21 at 7:53











  • How do you update view if request received from webservice (Rest or soap)?

    – mah454
    Jan 21 at 19:53






  • 1





    The response should come from A service. The implementation of tbat service should be hidden from calling or depending services. For callback to the caller use an observer ;ike posted in the link

    – Kukeltje
    Jan 21 at 21:59











  • @Kukeltje "@Observer" not working with viewScoped bean . How can fix this problem ?

    – mah454
    Jan 24 at 9:19











  • How is it not working with a viewscoped bean? And please make an Minimal, Complete, and Verifiable example and do you actually need the 'push' related bean to be a viewsoped bean?

    – Kukeltje
    Jan 24 at 10:07



















It is bad practice to add front-end technology (Push) in backend services. The link you posted contains the info to do it right and it works (I use that all the time) And since you did not post what you tried before we cannot help and effectively this Q/A is sort of useless

– Kukeltje
Jan 21 at 7:53





It is bad practice to add front-end technology (Push) in backend services. The link you posted contains the info to do it right and it works (I use that all the time) And since you did not post what you tried before we cannot help and effectively this Q/A is sort of useless

– Kukeltje
Jan 21 at 7:53













How do you update view if request received from webservice (Rest or soap)?

– mah454
Jan 21 at 19:53





How do you update view if request received from webservice (Rest or soap)?

– mah454
Jan 21 at 19:53




1




1





The response should come from A service. The implementation of tbat service should be hidden from calling or depending services. For callback to the caller use an observer ;ike posted in the link

– Kukeltje
Jan 21 at 21:59





The response should come from A service. The implementation of tbat service should be hidden from calling or depending services. For callback to the caller use an observer ;ike posted in the link

– Kukeltje
Jan 21 at 21:59













@Kukeltje "@Observer" not working with viewScoped bean . How can fix this problem ?

– mah454
Jan 24 at 9:19





@Kukeltje "@Observer" not working with viewScoped bean . How can fix this problem ?

– mah454
Jan 24 at 9:19













How is it not working with a viewscoped bean? And please make an Minimal, Complete, and Verifiable example and do you actually need the 'push' related bean to be a viewsoped bean?

– Kukeltje
Jan 24 at 10:07







How is it not working with a viewscoped bean? And please make an Minimal, Complete, and Verifiable example and do you actually need the 'push' related bean to be a viewsoped bean?

– Kukeltje
Jan 24 at 10:07




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54264788%2fjsf-websocket-update-viewscope%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Liquibase includeAll doesn't find base path

How to use setInterval in EJS file?

Petrus Granier-Deferre