小编Rad*_*FID的帖子

Angular 路由器:重定向到 i18n URL

我有一个角度应用程序仅支持一种语言环境(法语)。然后,我改进了应用程序以支持另一种语言,其中相同的组件在另一个根路径下可用/ar

我现在的问题是应用程序使用了很多 [routerLink]="['some', 'thing'] 和其他 router.navigate('...')。而不是 i18n 所有链接,我正在考虑一个执行 url 转换的智能方法。

我做了以下事情:

this.translateService.onLangChange
.combineLatest(this.router.events)
.subscribe(([langEvent, event]) => {

    if (event instanceof NavigationStart) {
        let currentUrl = event.url;

        let locale = Locale.getLocaleByShortcut(langEvent.lang);

        if (locale) {
            if (locale.isArabic()) {
                if (!ContextUtils.isArabicUrl(currentUrl)) {
                    this.router.navigate(['/ar/' + currentUrl], {queryParams: this.route.snapshot.queryParams});
                }
            } else {
                if (ContextUtils.isArabicUrl(currentUrl)) {
                    let url = ContextUtils.frenchifyUrl(currentUrl);
                    this.router.navigate([url], {queryParams: this.route.snapshot.queryParams});
                }
            }
        }

    }

    if (event instanceof NavigationEnd) {

        if (Config.IS_WEB()) {
            $(document).ready(() =>
                setTimeout(() => {
                    Materialize.updateTextFields()
                }, 10)
            ); …
Run Code Online (Sandbox Code Playgroud)

angular-ui-router angular angular5

3
推荐指数
1
解决办法
7089
查看次数

Ubuntu 18.04与Intellij后退/前进导航冲突

Intellij在最后一个ubuntu版本18.04中导航Back Forward冲突.问题是,当我不想将新值分配给向左或向右导航到工作区时,我在快捷方式面板中找不到它们.

对此有何解决方案?

ubuntu intellij-idea ubuntu-18.04

3
推荐指数
1
解决办法
853
查看次数

Primefaces p:当onclick事件返回true时,menuitem不会触发事件

我正在使用PrimeFaces p:menuitem组件执行删除.为了添加确认步骤,我使用了onclick显示JavaScript确认对话框的事件.在我的代码下面:

<p:menuitem icon="fa fa-fw fa-remove"
    title="#{message.global_remove}"
    value="#{message.global_remove}"
    actionListener="#{componentListMB.delete(cp.id)}"
    onclick="return confirm('#{message.component_list_confirm_deletion}')"
    update=":component_list" />
Run Code Online (Sandbox Code Playgroud)

当用户确认删除时,不会触发该操作,而是#在URL的末尾添加a .

为什么在p:commandButton一切正常的情况下不会触发事件?


我正在使用:

  • JSF 2.1.7
  • Primefaces 6.0

javascript jsf primefaces jsf-2

1
推荐指数
1
解决办法
3453
查看次数

MapStruct:当@Named 注释时,列表映射不使用单个映射

我有以下映射器

@Mapper
@Named("RoleBaseMapper")
public interface RoleBaseMapper {

    @Mapping(target = "code", source = "name")
    @Named("mapToBase")
    RoleGuiBaseDto mapToBase(Role role);

    @Named("MapListToBase")
    List<RoleGuiBaseDto> mapListToBase(List<Role> roles);
}
Run Code Online (Sandbox Code Playgroud)

我期望的是,mapListToBase它将用于mapToBase映射列表中的每个条目。但是当我看到生成的代码时,我有以下内容

@Override
public List<RoleGuiBaseDto> mapListToBase(List<Role> roles) {
    if ( roles == null ) {
        return null;
    }

    List<RoleGuiBaseDto> list = new ArrayList<RoleGuiBaseDto>( roles.size() );
    for ( Role role : roles ) {
        list.add( roleToRoleGuiBaseDto( role ) );
    }

    return list;
}

protected RoleGuiBaseDto roleToRoleGuiBaseDto(Role role) {
    if ( role == null ) {
        return …
Run Code Online (Sandbox Code Playgroud)

java mapstruct

1
推荐指数
1
解决办法
1358
查看次数