久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Vaadin(流):使用共享對象導航到目的地

Vaadin (Flow): Navigating to destination with a shared object(Vaadin(流):使用共享對象導航到目的地)
本文介紹了Vaadin(流):使用共享對象導航到目的地的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我目前有一個顯示 SomeModel 類型內容的網格.當我單擊該 Grid 的條目時,我想導航到一個視圖,該視圖將對象作為其輸入以顯示條目內容.

I currently have a grid that displays content of type SomeModel. When I click an entry of that Grid I would like to navigate to a view that takes an object as its input to display the entries content.

為了實現這種行為,我創建了一個 DetailLayout,如下所示:

To achive this behaviour I created a DetailLayout like this:

public DetailLayout extends FlexLayout implements HasUrlParameter<SomeModel>{
    /* skipped some details */
    @Override
    public void setParameter(BeforeEvent event, Host parameter) {
        /* This is where I expected to be able to handle the object */
    }
}

Grid 我嘗試像這樣導航:

From within the Grid I tried to navigate like this:

addSelectionListener((event) -> {
    event.getFirstSelectedItem().ifPresent(somemodel -> {
        getUI().ifPresent(ui -> {
            ui.navigate(DetailLayout.class, somemodel);
        });
    });
});

但不幸的是,即使它的語法非常好,Vaadin 也不支持這種行為.

But unfortunately this behaviour is not supported by Vaadin even tho its syntax is perfectly fine.

您是否知道在導航時傳遞對象的另一種方法,或者我是否錯過了官方文檔的某個部分 文檔 ?

Do you know of another way to pass an object while navigation or did I miss a certain part of the official documentation documentation ?

提前謝謝你

推薦答案

Key-Value集合

如其他答案的評論中所述,如果您不希望將 ID 值作為URL,然后使用 Vaadin 提供的鍵值集合在幕后工作.

Key-Value collection

As discussed in the comments on the other Answer, if you do not wish to expose the ID value as part of the URL, then work behind the scenes by using the key-value collection provided by Vaadin.

Vaadin 實際上提供了三個范圍級別的鍵值集合:

Vaadin actually provides key-value collections at three levels of scope:

  • 上下文
    您的整個網絡應用在運行時
  • 會話
    每個用戶
  • UI
    每個網絡瀏覽器窗口/標簽,因為 Vaadin 支持多窗口網絡應用程序

通過 getAttribute & 在 VaadinContext 上可以使用應用范圍的鍵值集合setAttribute 方法.

The app-wide key-value collection is available on the VaadinContext, via getAttribute & setAttribute methods.

VaadinService.getCurrent().getContext().setAttribute( key , value ) ;

每個用戶的鍵值集合在 VaadinSession 上可用,通過 getAttribute &setAttribute 方法.

The per-user key-value collection is available on the VaadinSession, via getAttribute & setAttribute methods.

VaadinSession.getCurrent().setAttribute( key , value ) ;

? 每個瀏覽器窗口/選項卡的集合(您在本問題中想要滿足您的需求)并不那么容易獲得.你必須經過一個間接的步驟.在 ComponentUtil 類,調用 setData &getData 方法.除了 傳遞你的key和你的值,傳遞當前的UI對象.

? The per-browser-window/tab collection (what you want for your needs in this Question) is not quite so readily available. You have to go through an indirect step. On the ComponentUtil class, call setData & getData methods. In addition to passing your key and your value, pass the current UI object.

Component c = UI.getCurrent() ;
String key = "com.example.acmeapp.selectedProductId" ;
Object value = productId ;
ComponentUtil.setData( c , key , value ) ;

<小時>

請投票給我的 ticket #6287,一個功能請求添加 <UI 類的 code>setAttribute/getAttribute 方法,以匹配 VaadinSessionVaadinContext 的方法.


Please vote for my ticket # 6287, a feature-request to add setAttribute/getAttribute methods on UI class, to match those of VaadinSession and VaadinContext.

這篇關于Vaadin(流):使用共享對象導航到目的地的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Java Remove Duplicates from an Array?(Java從數組中刪除重復項?)
How to fix Invocation failed Unexpected Response from Server: Unauthorized in Android studio(如何修復調用失敗來自服務器的意外響應:在 Android 工作室中未經授權)
AES encryption, got extra trash characters in decrypted file(AES 加密,解密文件中有多余的垃圾字符)
AES Error: Given final block not properly padded(AES 錯誤:給定的最終塊未正確填充)
Detecting incorrect key using AES/GCM in JAVA(在 JAVA 中使用 AES/GCM 檢測不正確的密鑰)
AES-256-CBC in Java(Java 中的 AES-256-CBC)
主站蜘蛛池模板: 欧美精品91 | 久久免费视频2 | aaa大片免费观看 | 久久综合久色欧美综合狠狠 | 国产午夜精品福利 | 欧美a区| 91av在线免费 | 成人在线中文字幕 | 91视在线国内在线播放酒店 | 国产精品一区二区三区久久久 | 搞黄网站在线观看 | 久久久精品一区 | 国产在线一区二区三区 | 国产精品亚洲片在线播放 | 欧美精品在线一区二区三区 | 久久亚洲精品国产精品紫薇 | 在线观看黄视频 | 欧美一区二区三区在线观看 | 久久天天躁狠狠躁夜夜躁2014 | 欧美日韩一区二区三区视频 | 欧美日韩在线观看视频 | 色爱区综合 | 亚洲不卡一| 久久久久久亚洲欧洲 | 亚洲国产精品一区二区第一页 | 国产一区久久久 | 亚洲一区二区三区在线视频 | 欧美日韩高清在线一区 | 亚洲高清在线 | aaaaa毛片 | av中文字幕在线观看 | 国产乱码精品1区2区3区 | 96国产精品久久久久aⅴ四区 | 免费三级网 | 亚洲有码转帖 | 久久久久亚洲 | 欧美激情综合色综合啪啪五月 | 成人在线免费 | 午夜视频一区二区三区 | 国产真实乱对白精彩久久小说 | 中文字幕一区二区三 |