Sunday, August 7, 2016

Re: Access specific link from dynamically build FlexTable

I think that is different from the answer, but I thought that I if to hint.

I, using cookies, we implement this.
To set the cookie in the message, we try to show the message to people who do not have the message cookie.


public static Panel createInfomation(){

final VerticalPanel p_vp = new VerticalPanel();
final List<M_RpcInfo> p_not_read= new ArrayList<M_RpcInfo>();

final Label p_status = new Label("確認中");
p_vp.add(p_status);

final ServiceCommonAsync greetingService = GWT.create(ServiceCommon.class);
RpcCommuObj prc = RpcCommuObj.createObjListInfo(null, 1,new String[]{}, new String[]{}, "", 5, "info", false);
greetingService.getDaialogInfomationListForPanel(prc, new AsyncCallback<List<M_RpcInfo>>(){

@Override
public void onFailure(Throwable caught) {
p_status.setText(caught.getMessage());
}

@Override
public void onSuccess(final List<M_RpcInfo> result) {
final StringBuffer cnt=new StringBuffer();
cnt.append("0");
for(int i=0;i<result.size();i++){
String isRead=Cookies.getCookie("IS_READE_ID_"+result.get(i).getValue("id")+"_"+result.get(i).getValue("value01"));
if(isRead==null){

int p_cnt =Integer.valueOf(cnt.toString()).intValue()+1;
cnt.delete(0, cnt.length());
cnt.append(""+p_cnt);
p_not_read.add(result.get(i));
}
}
p_vp.remove(p_status);

HorizontalPanel p_hp2 = new HorizontalPanel();
Button p_btn = new Button("お知らせを表示");
HTML p_info= new HTML("未読<font style=\"color:red;\">" +cnt +"</font>件");
p_hp2.add(p_btn);
p_hp2.add(p_info);

p_vp.add(p_hp2);

p_btn.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event) {

final VerticalPanel p_vp_info = new VerticalPanel();
DialogBox p_dialog =KutTool.createDialog(p_vp_info);

if(Integer.valueOf(cnt.toString()).intValue()>0){
//p_vp.add(new Label("未読のお知らせが "+cnt +" 件あります"));

for(int i=0;i<p_not_read.size();i++){
final  Label p_info = new Label(p_not_read.get(i).getValue("value01"));
final String id=p_not_read.get(i).getValue("id");
HorizontalPanel p_hp = new HorizontalPanel();
p_info.setWidth("400px");
final Button p_btn_read = new Button("未読を消す");
p_btn_read.setWidth("100px");
p_vp_info.add(p_hp);
p_hp.add(p_info);
p_hp.add(p_btn_read);
p_vp_info.setBorderWidth(1);

p_btn_read.addClickHandler(new ClickHandler(){

@Override
public void onClick(ClickEvent event) {
Cookies.setCookie("IS_READE_ID_"+id+"_"+p_info.getText(),"true");
p_info.setVisible(false);
p_btn_read.setVisible(false);
p_vp.clear();
p_vp.add((VerticalPanel)KutTool.createInfomation());
}});
}
}
final Button p_btn_all = new Button("確認済みのお知らせ");
p_btn_all.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event) {
p_vp_info.clear();
p_vp_info.add(p_btn_all);
for(int i=0;i<result.size();i++){
final  Label result2 = new Label(result.get(i).getValue("value01"));
p_vp_info.add(result2);
}
}});
p_vp_info.add(p_btn_all);
p_dialog.show();
p_dialog.center();
}});
}});
return p_vp;
}



2016-08-08 2:12 GMT+09:00 Olar Andrei <olarandrei@gmail.com>:
Hello,

I have to implement a messaging system for my application. I want all my conversations to be visible and the user should select one of those to open.
I'm creating a FlexTable from a List of Conversations returned to me via RPC.

My ideea to select one conversation of all available was to link the subject column with a normal servlet getting the id as a parameter.
But the ideea is I do not want to open another page to display the conversation. I want to display it on the same page. I wan't to clear the existing widget and create a new one with all the messages in the selected conversation.

How can I do that ? Link to GWT what was clicked, in order for it to clear the current widget and create a new one...
Or is there a better idea ? Like can it be done through RPC ?

Thanks in advance,
Andrei


DBGetAllConversationsAsync rpc = (DBGetAllConversationsAsync) GWT.create(DBGetAllConversations.class);
ServiceDefTarget tar = (ServiceDefTarget) rpc;
String moduleURL = GWT.getModuleBaseURL() + "DBGetAllConversationsImpl";
tar.setServiceEntryPoint(moduleURL);

rpc.getAllMessages(userInfo, new AsyncCallback<List<Conversation>>() {

@Override
public void onSuccess(List<Conversation> result) {
DOM.getElementById("loading").getStyle().setDisplay(Display.NONE);

int start = 1;

for (Conversation conversation : result) {
int id = conversation.getId();

flexTable.setHTML(start, 0, String.valueOf(id));
flexTable.setHTML(start, 1, conversation.getDate());

String username = userInfo.getUsername();
String source = conversation.getSource();
String destination = conversation.getDestination();

flexTable.setHTML(start, 2, source.equals(username) ? destination : source);
flexTable.setHTML(start, 3,
"<a href=\"" + GWT.getModuleBaseURL() + "viewConversation?id=" + id + "\">" + conversation.getSubject() + "</a>");
flexTable.setHTML(start, 4, "0");
flexTable.setHTML(start, 5, "Unread");

start++;
}

}

@Override
public void onFailure(Throwable caught) {
...

}
});


--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment